help-octave
[Top][All Lists]
Advanced

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

Re: num2str() question


From: Steven Levine
Subject: Re: num2str() question
Date: Thu, 25 Sep 2003 22:51:48 -0700

In <address@hidden>, on 09/25/03
   at 08:15 PM, "John B. Thoo" <address@hidden> said:

>Why doesn't num2str() return 10000 instead of 1e+04 in the last
>instance?  And how do I make it return 10000?

The Octave online help is your friend:

 - Function File:  num2str (X)
     Convert a number to a string.  These functions are not very
     flexible, but are provided for compatibility with MATLAB.  For
     better control over the results, use `sprintf' (*note Formatted
     Output::.).

Since it's a function file, you can look at the code, which in my version
of Octave says:

 retval = sprintf ("%g", x);

so whatever controls the %g formatting controls the num2str formatting.
There's probably a global variable to control the cutover from fixed point
to exponential format.  I don't recall it offhand, so I'll leave it to you
to find it in the help.

HTH,

Steven

--
----------------------------------------------------------------------
"Steven Levine" <address@hidden>  MR2/ICE 2.37 #10183
Warp4/FP15/14.093c_W4 www.scoug.com irc.webbnet.info irc.fyrelizard.org
#scoug (Wed 7pm PST)
----------------------------------------------------------------------



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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