BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

 


@smercurio_fc wrote:

@Jeff Bohrer wrote:

a few ways to skin the cat


Yeah. I just assumed there was a reason for the indicator being an I32.

 

Ray: is there something more going on?


I could not imagine a reason to maintain a I32 representation.  The sign bit is masked the lo(x) of a I32 is a U16 by definition.? Ray?
Scientists STAND on the shoulders of giants! They don't ride "piggyback" to keep their heads down.

"Should be" isn't "Is" -Jay
Message 911 of 2,238
(1,285 Views)

For a simple indicator, the representation will of course be irrelevant.

 

Often however the value is used in further processing and the number of bits will matter. Without additional knowledge, we need to assume that the I32 representation of the indicator in the original code is significant. We cannot change specifications on the fly. 😄


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 912 of 2,238
(1,282 Views)

@altenbach wrote:

For a simple indicator, the representation will of course be irrelevant.

 

Often however the value is used in further processing and the number of bits will matter. Without additional knowledge, we need to assume that the I32 representation of the indicator in the original code is significant. We cannot change specifications on the fly. 😄


(My emphasis). Indeed. For instance, if you had used the To Word Integer (I16) instead of the To Unsigned Word Integer (U16), then a value like 7AF123 would get you the I32 value filled up with Fs for the upper bytes (FFFFF123). Hence, in this case the representation of the indicator would matter, so to speak.

0 Kudos
Message 913 of 2,238
(1,276 Views)

Thanks guys!

 

As soon as I saw Christian's example I went "AAAAAAAAAHHHHHHHRRRRGGGGHHHH!!!!!!!"

That was how I did it.  Even in C.  Deuh!

 

Not doing anything special.  Just braindead.. 

 Now I am convinced that I need to go outside, see the sun and get some fresh air.

 

Thanks.  At least people (and I ) will know that there are alternatives.

 

Kudos guys

 

The number gets converted to a double with some additional math afterwards.  Nothing complicated.  Two U16 are stored within 32 bit registers.  Hence the reason to extract the upper & lower 16 bits.

______________________________________________________________________
0 Kudos
Message 914 of 2,238
(1,264 Views)

I forgot to mention that Jeff's solution was the chosen one 🙂

 

Now I go for a walk...

______________________________________________________________________
0 Kudos
Message 915 of 2,238
(1,255 Views)

@Ray.R wrote:

I forgot to mention that Jeff's solution was the chosen one 🙂

 

Now I go for a walk...


Well, then. Finally after 92 pages this thread has a solution! Woo-hoo!!! Smiley Very Happy

Message 916 of 2,238
(1,251 Views)

 


@altenbach wrote:

For a simple indicator, the representation will of course be irrelevant.

 

Often however the value is used in further processing and the number of bits will matter. Without additional knowledge, we need to assume that the I32 representation of the indicator in the original code is significant. We cannot change specifications on the fly. 😄


Ray wrote.

I want to extract the lower 16 bits of a number.

 


Lesson- read the spec.  never trust the original developer met the requirements.  Clearly a 16bit data type was the desired output.  Smiley Very HappySmiley Wink

 

enjoy the  sunshine

Scientists STAND on the shoulders of giants! They don't ride "piggyback" to keep their heads down.

"Should be" isn't "Is" -Jay
Message 917 of 2,238
(1,245 Views)

Since the word "extract" is too ambiguous (What does it mean??), I went with Ray's output representation as used in the snippet and which was hinted as correct, but just rube-ish. 😄


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 918 of 2,238
(1,239 Views)

@Ray.R wrote:

Hence the reason to extract the upper & lower 16 bits.


While AND is usually my choice for a masking operation (extracting certain bits), I tend to go with Mod math to split a number which seems to be the case here.

 

ExtractBits.png

 

(Generalized version of Split Number)

Message 919 of 2,238
(1,228 Views)

The sunshine was brief  😞  Access to the station I am working on is limited..  Can't let sunshine get in the way..

 

Any of you guys in SC?

 

Jeff's purty good at extractin' the requirements... or mind-readin'

______________________________________________________________________
0 Kudos
Message 920 of 2,238
(1,220 Views)