Import data with 5 digits

Hi all !

How can I import data with 5 digits via Import wizard / Import ASCII ?

My imports are always truncated to 4 digits.

I am grateful for any links or advice.

P

TY Cougar, very helpful

1 Like

The above response is wrong. There is absolutely NO NEED to use scientific notation. Original poster is also wrong. Computers do NOT use decimal digits. Everything is stored in binary. What he looks at is the formatting of numbers for display and it has nothing to do with import. Formatting can be done to any number of digits. Precision/resolution is another story. Typically IEEE single floating point has 7 significant digits of precision. http://www.amibroker.com/kb/2010/07/20/about-floating-point-arithmetic/

1 Like

How do I import bond prices then ?
format: 100.12345

TY

random login today to see if any new updates were there and i saw this post.

I actually read something like this but i cant find that thread,
what i did find was this post

but if all the data is stored as 32bit IEEE single floating point has 7 significant digits of precision as mentioned by Mr Tomasz, then basically you cannot store/import those bond prices to the 5th decimal because you have to count from 1st non zero digit from the left.

That is common misconception. Actual precision of IEEE representation depends on actual number stored. The numbers that are binary (power of 2) fractions can go beyond 8 significant digit, example:
The numbers:
100.03125 (8 significant digits)
100.015625 (9 significant digits)
100.0078125 (10 significant digits)

are represented accurately in single precision floating number. Why? Because the fractions presented in the numbers above happen to be negative powers of 2 and have limited binary representation.

You can try this:

printf( "%.12f", 100.0078125  );

Also fractions being combinations of powers of 2 are accurate beyond 7 digit. For example:

100.0546875 is a sum of 100 + 0.03125 + 0.015625 + 0.0078125 has 10 significant digits and is represented accurately.

printf( "%.12f", 100.0546875 );

As it happens those weird prices of bonds often come from the fact that they are quoted in 1/32 or 1/64 fractions. And they happen to be negative powers of 2 and as such have finite binary representation.

The code below generates numbers like 100 + N/64 where N = 0..64 showing you that all 64nd fractions are accurate.

for( i = 0; i <= 64; i++ )
{
  printf( "100 + %g/64 = %.12f\n", i, 100 + (i/64) );
}

Output:

100 + 0/64 = 100.000000000000
100 + 1/64 = 100.015625000000
100 + 2/64 = 100.031250000000
100 + 3/64 = 100.046875000000
100 + 4/64 = 100.062500000000
100 + 5/64 = 100.078125000000
100 + 6/64 = 100.093750000000
100 + 7/64 = 100.109375000000
100 + 8/64 = 100.125000000000
100 + 9/64 = 100.140625000000
100 + 10/64 = 100.156250000000
100 + 11/64 = 100.171875000000
100 + 12/64 = 100.187500000000
100 + 13/64 = 100.203125000000
100 + 14/64 = 100.218750000000
100 + 15/64 = 100.234375000000
100 + 16/64 = 100.250000000000
100 + 17/64 = 100.265625000000
100 + 18/64 = 100.281250000000
100 + 19/64 = 100.296875000000
100 + 20/64 = 100.312500000000
100 + 21/64 = 100.328125000000
100 + 22/64 = 100.343750000000
100 + 23/64 = 100.359375000000
100 + 24/64 = 100.375000000000
100 + 25/64 = 100.390625000000
100 + 26/64 = 100.406250000000
100 + 27/64 = 100.421875000000
100 + 28/64 = 100.437500000000
100 + 29/64 = 100.453125000000
100 + 30/64 = 100.468750000000
100 + 31/64 = 100.484375000000
100 + 32/64 = 100.500000000000
100 + 33/64 = 100.515625000000
100 + 34/64 = 100.531250000000
100 + 35/64 = 100.546875000000
100 + 36/64 = 100.562500000000
100 + 37/64 = 100.578125000000
100 + 38/64 = 100.593750000000
100 + 39/64 = 100.609375000000
100 + 40/64 = 100.625000000000
100 + 41/64 = 100.640625000000
100 + 42/64 = 100.656250000000
100 + 43/64 = 100.671875000000
100 + 44/64 = 100.687500000000
100 + 45/64 = 100.703125000000
100 + 46/64 = 100.718750000000
100 + 47/64 = 100.734375000000
100 + 48/64 = 100.750000000000
100 + 49/64 = 100.765625000000
100 + 50/64 = 100.781250000000
100 + 51/64 = 100.796875000000
100 + 52/64 = 100.812500000000
100 + 53/64 = 100.828125000000
100 + 54/64 = 100.843750000000
100 + 55/64 = 100.859375000000
100 + 56/64 = 100.875000000000
100 + 57/64 = 100.890625000000
100 + 58/64 = 100.906250000000
100 + 59/64 = 100.921875000000
100 + 60/64 = 100.937500000000
100 + 61/64 = 100.953125000000
100 + 62/64 = 100.968750000000
100 + 63/64 = 100.984375000000
100 + 64/64 = 101.000000000000

You can try this on Nth being other power of 2. For example N/16384 work too:

Nth = 16384;
for( i = 0; i <= Nth; i++ )
{
  printf( "100 + %g/%g = %.16f\n", i,  Nth, 100 + (i/Nth) );
}

You can use calculator like this:
https://www.h-schmidt.net/FloatConverter/IEEE754.html
to find out how number is represented in binary and if it is rounded or not.

The usually quoted number of 7 significant digits applies to fractions that have infinite binary representation (or binary mantisa longer than 24 bits)

4 Likes