negative bits
Claus Dreischer
claus at dreischer.de
Wed Apr 2 12:11:37 EDT 2008
Hi Bill,
not even close ;-)
(just kidding)
I needed to generate a sinus table with that generic bit representation (two's-complement) for a VHDL project.
Two's-complement is the internal format in which signed integers are stored.
Rev and Mark saved me.
Regards,
Claus.
----- original Nachricht --------
Betreff: Re: negative bits
Gesendet: Mi, 02. Apr 2008
Von: Bill Marriott<wjm at wjm.org>
> 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=CH0625282410
> 33
>
> 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.
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
--- original Nachricht Ende ----
More information about the use-livecode
mailing list