LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a negative floating point number to is two's complement and display the results?

I want to convert a negative floating point number to its two's complement and display the result in a boolean array. I tried the "number to boolean array" function but it did not work with negative numbers.
0 Kudos
Message 1 of 4
(4,920 Views)
> I want to convert a negative floating point number to its two's
> complement and display the result in a boolean array. I tried the
> "number to boolean array" function but it did not work with negative
> numbers.
>

Note that the Number to Boolean Array function works on integers. The
float is being converted to an integer at the coercion dot and the
convertor is working on the integer.

To do this on a float, you can split it into the integer and fraction.
Use the convertor for the integer portion, then build a convertor for
the fraction. Multiply the fraction by two, write the integer portion
into the array, separate out the fraction portion and repeat until the
value goes to zero or you collect as many digits as you like. Collect
the array elem
ents from left to right. Finally combine the portions
together.

Greg McKaskle
0 Kudos
Message 2 of 4
(4,920 Views)
Hallo, lone_progmr,

Du (x) meintest am 04.12.01:

> I want to convert a negative floating point number to its two's
> complement and display the result in a boolean array.

That may be beyond of mathematic definitions ...

The 2-complement is either
not + 1

or


In both cases I suppose there are no floating point numbers allowed.

Greetings!
Helmut

Please excuse my gerlish!
0 Kudos
Message 3 of 4
(4,920 Views)
If you have a negative floating point number and want to have the binary representation of it, you could use this VI. It converts any floating point number (Double precision) to its 64 bit representation following the IEEE-754 standard. This is done by using the Type Cast function followed by some binary array operations (to get the 64 bit array). In the VI I also included a www-reference to the IEEE-754 standard. I hope this helps. /Mikael
Message 4 of 4
(4,920 Views)