BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Brain teaser

OK, here's some very simple code:

 

(nothing hidden, constants formatted as %016b, representations exactly as indicated(U8, U16, I8))

 

altenbach_0-1578623264455.png

 

Without using LabVIEW (i.e. paper&pencil), what are the results for Numeric A and Numeric B?

 

(Now wire it up and see if you were right. Explain the result. :D)

Message 1 of 4
(5,735 Views)

I'd say read the detailed help for Boolean Array to Number, but the key ingredient is missing from the documentation.  For a hint, right-click on a Boolean Array to Number Function.  Second-nature to bit-bangers but easy to see the potential for confusion.

Message 2 of 4
(5,704 Views)

The I8 is -1, so when converted, apparently it becomes a -1 16 bit signed number before becoming unsigned. So, it becomes 0xFFFF, or b1111111111111111... Of course, To Unsigned Word Integer also does this.

 

It met my expectation, but that expectation a was biased with suspicion from this question. It would be easy to get lost when found in the wild.

 

I had to deal with similar stuff fairly recent. Signed and unsigned Integers with arbitrary nr of bits, need to be converted to I64's (as a general container).

 

It's weird that there is a IEEE for floating point (conversion), but not for integers.

 

These functions are available on the CPU, as CBW, CWD and CDQ. AFAIK, in assembler, there's no distinguishing between signed and unsigned values (on normal, non mmx\fp registers), this must come from the way you deal with the values.

Message 3 of 4
(5,672 Views)

My answer to this case would have been wrong!

I8 to U16.png
 
Thank you Christian for this interesting question.
Message 4 of 4
(5,639 Views)