Hi Longtao,
Thanks for clarifying this offline.
We don't have a function specifically to do this, but you could do it using a UNIX command executed with "systemfunc". Here's a sample function and main code that calls it:
function dectobin(dec_num:integer)
local dq, cmd
begin
;---Double quote character
dq = str_get_dq()
;---UNIX command that converts decimal to binary
cmd = "echo " + dq + "ibase=10;obase=2;" + dq + dec_num + " | bc "
;---Execute UNIX command and return an integer
return(toint(systemfunc(cmd)))
end
; Main code
;---Decimal number to convert
begin
dec_num = 7
bin_num = dectobin(dec_num)
print("decimal number = " + dec_num)
print("binary number = " + bin_num)
end
--Mary
On Sep 7, 2010, at 5:01 PM, WuLongtao wrote:
> Hello,
>
> How to convert a certain number (Uint_16) to binary in NCL?
>
> Thanks!
>
> -Longtao
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 14 09:29:33 2010
This archive was generated by hypermail 2.1.8 : Thu Sep 16 2010 - 11:05:24 MDT