octave-maintainers
[Top][All Lists]
Advanced

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

Re: Help with format long


From: michele
Subject: Re: Help with format long
Date: Fri, 16 Feb 2018 15:46:35 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 02/16/2018 03:41 PM, Rik wrote:
Could someone try the following code in Matlab?  The documentation says
they keep 15 digits after the decimal point for the long format, but
frankly that would be misleading to the programmer.  IEEE-854 has 15-17
significant figures when represented in base 10, and there is no reason to
attempt to show more precision if it does not actually exists, as would be
the case if some of the significant digits occur before the decimal point.

Code:

format long
x = pi;
y = [x; x*10; x*100; x*1000]
single (y)

Thanks,
Rik


-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------

Dear Rik,

Matlab2017b gives

y =

   1.0e+03 *

   0.003141592653590
   0.031415926535898
   0.314159265358979
   3.141592653589793


ans =

  4×1 single column vector

   1.0e+03 *

   0.0031416
   0.0314159
   0.3141593
   3.1415928

--
Michele Ginesi




reply via email to

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