LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

maximum number in a Single precision floating number

Hi everyone,
 
I would like to know which is the maximum positive and negative number I can write in a SGL numeric control. I read the Numeric data types table  in the LabVIEW help and I am not sure if the numbers in the column "approximate range on disk" are the maximun and minimum ones because I wrote in a DBL numeric control the number 6216825840 (which is less than the maximum on the table 3.40e+38) and I displayed it in a SGL numeric indicator, and the number changed. 
 
The problem is that I am storing some data in the numeric format and  I choose the SGL format because it uses less space in the disk, however I have the number 6216825840 which changes if it is storaged in this format. I know that I should change to DBL, but I am doing an array with all my data and if I change one by BDL the other ones change to DBL and will use more space in the disk when I store them.
 
I attach a picture of this problem.
 
Thanks in advance.
 
JC
0 Kudos
Message 1 of 7
(6,381 Views)


JCNT wrote:
 
I would like to know which is the maximum positive and negative number I can write in a SGL numeric control. ....

I wrote in a DBL numeric control the number 6216825840 (which is less than the maximum on the table 3.40e+38) and I displayed it in a SGL numeric indicator, and the number changed. 


This is a precision problem/limitation, not a max/min problem.

SGL is limited to ~7 digits precision.
With DBL, you have ~15 digits precision.

=====================================================
Fading out. " ... J. Arthur Rank on gong."
0 Kudos
Message 2 of 7
(6,351 Views)
Hi Donald,
 
Thanks for reply,
 
You mean that I could  just write until the number 9999999?
 
JC
0 Kudos
Message 3 of 7
(6,349 Views)


@JCNT wrote:
You mean that I could  just write until the number 9999999?


No.  You are not limited to 7 digit numbers ... as shown by the 10 digit SGL 6216825856 in your JPG.

But a SGL cannot give you precision beyond the 7th digit: 6216825xxx

Message Edited by Donald on 06-15-2007 03:40 PM

=====================================================
Fading out. " ... J. Arthur Rank on gong."
Message 4 of 7
(6,338 Views)
And since the numbers are stored in binary, the resolution in decimal digits is just approximate.
 
SGL has a 23 bit mantissa (http://en.wikipedia.org/wiki/Single_precision), so you cannot do better than 2^24 for integers.
 
Your number does not even fit into a U32, which has all 32 bits reserved for the integer part. 😮
 
(DBL has a 52 bit mantissa.)
0 Kudos
Message 5 of 7
(6,323 Views)
In particular, you can create a simple test program that shows you that the highest good integer is 16777216 for SGL, because 16777216+1=16777216.
 
For deep reasons, this is the same as 2^24 as mentioned above. 🙂
 
Here's a quick code that stops the loop once i = i+1, then displays i (the fist integer that fails the test, thus is the largest good integer for SGL. 🙂
 

Message Edited by altenbach on 06-15-2007 01:33 PM

Message 6 of 7
(6,320 Views)
Hi Donald and altenbach,
 
Thanks so much both of you for your help, now I understand what you mean. So, I don't have any choice and I must store my data in DBL format.
 
Thanks again and I'm really glad that there are people like you who help people with these problems.
 
Regards from Ecuador!
 
JC
 
 
0 Kudos
Message 7 of 7
(6,298 Views)