Would it not work to simply multiply the value in question by the number of unique integers you wish to approximate, and take the integer portion of the result?
print int(.99 * 4); # output = 3 print int(.2 * 4); # output = 0
From there you simply need to convert the resulting number into a binary value. For that, use pack.
In reply to Re: Converting decimals to binary
by JediWizard
in thread Converting decimals to binary
by ketema
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |