LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

generate 3 digits floating point random number

hai....How I want to generate 3 digits floating point random number??..plz help me...
Thanks..
0 Kudos
Message 1 of 7
(3,748 Views)
I want to get the number from 1-5 in 3 digits floating point. For example 3.57. So I have no idea how to get the 3 digits floating point number. Can anyone help me..
 
Thanks 
0 Kudos
Message 2 of 7
(3,743 Views)

Hi gdah,

try this. Smiley Happy

<>

 

Hope it helps.

Mike



Message Edited by MikeS81 on 05-05-2008 09:30 AM
0 Kudos
Message 3 of 7
(3,742 Views)
Floating point numbers have a width expressed by bytes (e.g. double = 8 byte), not in digits. So "digits" in general are a display-thing.
If you choose to "limit" the precision to 3 digits, you can either configure your displays (indicators) to the proper settings (context menu => Display format) or you manually truncate your floating points to 3 digits by converting them either to string and truncate there and revert them to floating points or to convert them in a proper way to integers and back again...

hope this helps,
Norbert


Message Edited by Norbert B on 05-05-2008 02:32 AM
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 7
(3,734 Views)
Hi gdah,

use some common math functions to get a randopm number in the range from 1 to 5 (but not including 5, see help for "random number"!)... Then format to a string (if needed) or set properties of numeric indicator...


Hey Mike, your first version looked quite different Smiley Very Happy


Message Edited by GerdW on 05-05-2008 09:39 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(3,728 Views)
Remember that internally to the computer all numbers are expressed as binary. So the number of digits in a decimal expression does not correlate directly with the number of binary bits the computer uses to represent the same number. 0.2, 0.3, and 0.4 for example all have infinitely repeating repeating representations in binary. If you want to limit the size or precision of the numbers in calculations, you should determine the limits in accord with the binary representation of the numbers.

Lynn
0 Kudos
Message 6 of 7
(3,682 Views)
helo there...thanks for yor help...
thanks a lot  Smiley Happy
0 Kudos
Message 7 of 7
(3,657 Views)