乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      [20191013]oracle number類型存儲轉(zhuǎn)化腳本.txt

       丹楓無跡 2022-05-07 發(fā)布于北京

      [20191013]oracle number類型存儲轉(zhuǎn)化腳本.txt

      --//測試看看是否可以利用bc obase=100的輸出解決問題。另外以前腳本忘記考慮尾數(shù)的四舍五入問題。
      --//也許編程就是這樣,總有一些細(xì)節(jié)沒有考慮到...
      --//代碼如下num2raw_5.sh:

      #! /bin/bash
      #! number convert oracle raw.

      odebug=${ODEBUG:-0}

      # process input parameter ,delete "," and all spaces. save to variable v_num. and length to variable v_len.
      v_num="$*"
      v_num=${v_num//[, ]/}

      # strip e or trailing 0s in decimals or 0000.000 output 0 ,
      v_num=$(echo $v_num/1 + 0 | sed -e "s/[eE]+\?/*10^/" -e "s/^/scale=180;/" | bc | tr -d '\n\\\r' | sed -e "s/\.\([0-9]*[1-9]\)0\+$/.\1/" -e "s/\.0\+$//")

      if [[ "$v_num" =~ ^-.*$ ]]; then
          v_sign=1
          v_num=${v_num:1:180}
      else
          v_sign=0
      fi

      if [ $odebug -eq 1 ] ; then
          echo v_num="$v_num"
      fi    

      v_res=""
      if [ "$v_num" == "0" ]; then
          v_res="80"
          echo "$v_res"
          exit 0
      fi

      v_pos=$(expr index $v_num ".")

      if [ $v_pos -gt 1 ]; then
          v_exp=$(( v_pos/2 ))
      elif [ $v_pos -eq 0 ]; then
          v_exp=$(( (${#v_num}+1) /2 ))
      elif [ $v_pos -eq 1 ]; then
          v_tmp1=${v_num:1:180}
          v_tmp2=$(echo $v_tmp1 | sed 's/^0\+//g')
          v_exp=$(( (${#v_tmp2} - ${#v_tmp1})/2 ))
      fi

      v_exp1=$(printf "%02x" $(( $v_exp+192 )))
      if [ $v_sign -eq 1 ]; then
          v_exp1=$(printf "%02x" $(( 0xff - 0x${v_exp1} )))
      fi

      v_res=${v_exp1}${v_res}

      # oracle number type max length is 22 bytes (not 22 is 21 bytes??), 1 bytes exponent.
      # bc不作四舍五入,要加5*10^-41解決問題。
      v_tmp=$(echo "scale=180 ; a=$v_num / 100^($v_exp) +5*10^-41; scale=40;a/1 " | bc | tr -d '\n\\\r'| sed -e "s/\.\([0-9]*[1-9]\)0\+$/.\1/" -e "s/\.0\+$//" )

      if [ $odebug -eq 1 ] ; then
          echo v_num="$v_num" v_len="$v_len" v_exp="$v_exp" v_exp1="$v_exp1" v_tmp="$v_tmp"
      fi    

      if [ $v_sign -eq 0 ]; then
          v_res=${v_res}$(echo "obase=100;$v_tmp"  | bc | tr -d "." | awk 'BEGIN{RS=" +"}/./{printf ",%02x", $1+1}')
      else
          v_res=${v_res}$(echo "obase=100;$v_tmp"  | bc | tr -d "." | awk 'BEGIN{RS=" +"}/./{printf ",%02x", 101-$1}')
      fi

      if [ $v_sign -eq 1 -a ${#v_tmp} -lt 40 ]; then
          v_res=${v_res}",""66"
      fi

      echo "$v_res"

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多