LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Lottery Generator

Solved!
Go to solution

I meant using the rifle VI from the palette. Smiley Wink


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 21 of 24
(214 Views)

Wow. Some amazing insights in here. 

 

Can I ask why the scale by power of two is used rather than multiply?

0 Kudos
Message 22 of 24
(189 Views)

@StevenD wrote:

Wow. Some amazing insights in here. 

 

Can I ask why the scale by power of two is used rather than multiply?


I will wait to hear from Christian and learn as well but I can observe that a scale by a power of two in binary is simply an arithmetic shift left.

 

Ben

0 Kudos
Message 23 of 24
(181 Views)

StevenD wrote:

Can I ask why the scale by power of two is used rather than multiply?


Multiply is probably a better choice here, because the price can change by a random amount. A multiplication/division by integer powers of two corresponds to an arithmetic shift (not logical shift, important difference when the input is negative) for integers. Even for floating point numbers, only a subset of bits need to be touched, but I doubt it would make a difference on a modern processor (but would be of great help when using paper& pencil Smiley Happy).

 

So, yes we should use multiplication here. Shifts/powers of two should be used where it is more natural, e.g. if you would implement the cooley-tuckey fft or a binary search. Sorry about that.


LabVIEW Champion Do more with less code and in less time
Message 24 of 24
(173 Views)