help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fprintf long integers


From: João Rodrigues
Subject: fprintf long integers
Date: Sun, 14 Sep 2014 20:59:56 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0


Dear list members

I want to use fprintf to generate mixed string and numeric data but it seems that fprint f does not handle well integers longer than 8 characters.

The code below generates number 1*1 where * goes from no zero to 20 zeros, in both float and integer format. My conclusion is that in Octave integers are stored with 8 digits and floats with 16.

Is there a way to force Octave to recognize a number as a long integer?

(For my problem 16 digits would be sufficient. The example goes up to 20 to show the limit for floats too.)

Thanks

octave:1> a = [0:20]; b = 10.^a+1;
octave:2> fprintf(stdout,"%3d %24.22g %24d \n",[a;b;b]);
  0                        2                        2
  1                       11                       11
  2                      101                      101
  3                     1001                     1001
  4                    10001                    10001
  5                   100001                   100001
  6                  1000001                  1000001
  7                 10000001                 10000001
  8                100000001                100000001
  9               1000000001               1000000001
 10              10000000001               1410065409
 11             100000000001               1215752193
 12            1000000000001               -727379967
 13           10000000000001               1316134913
 14          100000000000001                276447233
 15         1000000000000001              -1530494975
 16        10000000000000000               1874919424
 17       100000000000000000               1569325056
 18      1000000000000000000              -1486618624
 19     10000000000000000000     10000000000000000000
 20    100000000000000000000    100000000000000000000




reply via email to

[Prev in Thread] Current Thread [Next in Thread]