negative bits
Bill Marriott
wjm at wjm.org
Wed Apr 2 11:42:28 EDT 2008
Hi Claus,
I assume the reason why you're anticipating this result is because you are
used to Excel's DEC2BIN function available with the Analysis Add-On feature.
http://office.microsoft.com/en-us/excel/HP052090531033.aspx?pid=CH062528241033
Excel's DEC2BIN can only handle values between -512 to +511. And the results
it produces will of course be numbers that don't convert back the way you
expect in Revolution, either. For example, 11110111 is 247 in Rev.
If you want to get results consistent with Excel, the answer is to create
your own custom functions, DEC2BIN and BIN2DEC, that follow Excel's rules.
- Bill
"Claus Dreischer" <claus at dreischer.de> wrote in
message news:200804021410.m32EAEpc014923 at post.webmailer.de...
Hi,
maybe someone has done this already ...
I'd like to convert integers into binary ones and zeros like
input: "9" -> output "1001" or depending on the size of the output:
"00001001"
This can be done with the baseConvert function:
baseConvert( 9, 10, 2 ) gets me my "1001"
BUT (and we finaly get to the point)
converting a *negative* integer number won't get me the desired result:
baseconvert( -9, 10, 2 ) -> "-1001"
The anticipated result would be "11110111"
So, how do i get there?
Am i missing something?
Regards,
Claus.
More information about the use-livecode
mailing list