help-octave
[Top][All Lists]
Advanced

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

format long not working as expected


From: Jeff Sadowski
Subject: format long not working as expected
Date: Wed, 4 Oct 2017 08:48:19 -0600

I'm using octave 4.0.0 on ubuntu 16.04
when I do

>> format long
>> h=10.^(-15:-1)
h =

 Columns 1 through 6:

   1.00000000000000e-15   1.00000000000000e-14   1.00000000000000e-13   1.00000000000000e-12   1.00000000000000e-11   1.00000000000000e-10

 Columns 7 through 12:

   1.00000000000000e-09   1.00000000000000e-08   1.00000000000000e-07   1.00000000000000e-06   1.00000000000000e-05   1.00000000000000e-04

 Columns 13 through 15:

   1.00000000000000e-03   1.00000000000000e-02   1.00000000000000e-01

>> arrayfun(@(x) ((exp(x)-1)/x)-1,h)
ans =

 Columns 1 through 6:

   1.10223024625156e-01  -7.99277837359891e-04  -7.99277837359780e-04   8.89005823403455e-05   8.27403703329566e-08   8.27403705550012e-08

 Columns 7 through 12:

   8.27403705550012e-08  -6.07747152603366e-09   4.94336798162465e-08   4.99962183209135e-07   5.00000696446179e-06   5.00016671407533e-05

 Columns 13 through 15:

   5.00166708384375e-04   5.01670841679469e-03   5.17091807564771e-02

>>

The expected is like matlabs

>> format long
>>  h=10.^(-15:-1)

h =

  Columns 1 through 4

   0.000000000000001   0.000000000000010   0.000000000000100   0.000000000001000

  Columns 5 through 8

   0.000000000010000   0.000000000100000   0.000000001000000   0.000000010000000

  Columns 9 through 12

   0.000000100000000   0.000001000000000   0.000010000000000   0.000100000000000

  Columns 13 through 15

   0.001000000000000   0.010000000000000   0.100000000000000

>> arrayfun(@(x) ((exp(x)-1)/x)-1,h)

ans =

  Columns 1 through 4

   0.110223024625157  -0.000799277837359  -0.000799277837359   0.000088900582341

  Columns 5 through 8

   0.000000082740371   0.000000082740371   0.000000082740371  -0.000000006077471

  Columns 9 through 12

   0.000000049433680   0.000000499962184   0.000005000006965   0.000050001667141

  Columns 13 through 15

   0.000500166708385   0.005016708416795   0.051709180756477

>> 

reading the help in octave
     'long'
          Fixed point format with 15 significant figures in a field that
          is a maximum of 20 characters wide.

          As with the 'short' format, Octave will switch to an
          exponential 'e' format if it is unable to format a matrix
          properly using the current format.




reply via email to

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