Mailing List Archive: 49091 messages

# "scientific notation"

### [1/14] from: chalz:earthlink at: 8-Jan-2003 13:09

Errrm.
>> 1 / 100
== 1E-2 I don't want that. I want decimal. Even to-decimal doesn't give me a decimal. I don't want to deal with E's. How? --Charles

### [2/14] from: doug:vos:eds at: 8-Jan-2003 13:23

Try the function exp2dec (watch for wrapping)
>> exp2dec 1E-2
== "0.01" ;--------------------------------------------------------------------------- - exp2dec: func [ {Converts a number with a negative exponent (E-x) to its decimal bv equivalent. If the number must be converted, then a string will be returned. Otherwise the number sent to the function, N, will simply be returned.} N [number!] "The exponential number to convert." /local ret digit exp _get-dec-exp dec-numbers less-than-zero absn ][ ret: N less-than-zero: either (N < 0) ["-"][""] _get-dec-exp: func [ num [number!] /local shift _exp ][ shift: num _exp: 1 while [shift < 0.1][ shift: shift * 10 ;shifts a number until the fit _exp: _exp + 1 ] return _exp ] absn: abs(N) if (absn // 1 <> 0) [ exp: _get-dec-exp absn if (exp > 1) [ ret: make string! 10 insert/dup ret "0" (exp - 1) ;appends the zeros behind the decimal insert ret (join less-than-zero "0.") dec-numbers: make string! 10 dec-numbers: to-string absn dec-numbers: copy/part (find dec-numbers "E-") at dec-numbers 1 dec-numbers: rejoin parse dec-numbers "." foreach digit dec-numbers [ append ret digit ] ] ] return ret ] ;---------------------------------------------------------------------------

### [3/14] from: carl:cybercraft at: 9-Jan-2003 7:56

On 09-Jan-03, Charles wrote:
> Errrm. >>> 1 / 100 > == 1E-2 > I don't want that. I want decimal. Even to-decimal doesn't give > me a decimal. I don't want to deal with E's. How?
I get...
>> 1 / 10
== 0.1
>> 1 / 100
== 0.01
>> 1 / 1000
== 0.001
>> 1 / 10000
== 0.0001
>> 1 / 100000
== 1E-5 There must be a setting you've changed to get an E at 1 / 10. How you change it though I wouldn't know... -- Carl Read

### [4/14] from: anton:lexicon at: 9-Jan-2003 18:18

I get the same as Charles. I'm on windows and I get scientific notation. REBOL/View 1.2.8.3.1 3-Aug-2002 What versions are you guys running? Anton.

### [5/14] from: carl:cybercraft at: 9-Jan-2003 23:26

Just done some checks with View 1.2.1 on Amiga, Linux and Windows, and the E at 1 / 100 only happens with Windows. That's none too compatible, is it? Carl. On 09-Jan-03, Anton wrote:
> I get the same as Charles. > I'm on windows and I get scientific notation.
<<quoted lines omitted: 21>>

### [6/14] from: patrick:philipot:laposte at: 9-Jan-2003 12:25

Same for me, Windows 2000
>> 1 / 100
== 1E-2
>> system/version
== 1.2.8.3.1 Patrick

### [7/14] from: amicom::sonic::net at: 9-Jan-2003 8:20

This whole thing with Scientific Notation is related to the math libraries on your system. AFAIR, Rebol does not have its own in-built math libraries...it depends on the ones provided by the system (one of the few things Rebol doesn't have its own in-built libraries for). I'd agree that Windows is rather lame in using Scientific Notation after only two decimal places, but that is an issue with the Windows math libraries, not Rebol. Bohdan "Bo" Lechnowsky Lechnowsky Technical Consulting At 07:56 AM 1/9/03 +1300, you wrote:

### [8/14] from: carl:cybercraft at: 10-Jan-2003 9:06

On 10-Jan-03, Bohdan or Rosemary Lechnowsky wrote:
> This whole thing with Scientific Notation is related to the math > libraries on your system. AFAIR, Rebol does not have its own
<<quoted lines omitted: 3>>
> Scientific Notation after only two decimal places, but that is an > issue with the Windows math libraries, not Rebol.
I'd say it's an issue with REBOL, if REBOL's supposed to be a cross-platform language. I don't want to have consider which OS a script will be running on when I'm writing it, or write work-arounds for known differences. If REBOL for whatever reason can't have its own maths libraries, couldn't it at least convert decimals to a consistant format when we need to process them at the text level?
> At 07:56 AM 1/9/03 +1300, you wrote: >> On 09-Jan-03, Charles wrote:
<<quoted lines omitted: 18>>

### [9/14] from: amicom:sonic at: 9-Jan-2003 22:54

Carl, Having Rebol convert the format of decimal numbers sounds like a good idea. Perhaps submitting it to feedback will yield some future results! Bohdan "Bo" Lechnowsky Lechnowsky Technical Consulting At 09:06 AM 1/10/03 +1300, you wrote:

### [10/14] from: doug:vos:eds at: 10-Jan-2003 14:44

Has everyone who complained tried the function I provided that solves the problem? It seems to be a good work around for me, so I don't know what people are still complaining about? Please help me understand... Try the function exp2dec (watch for wrapping)
>> exp2dec 1E-2
== "0.01" ;--------------------------------------------------------------------------- - exp2dec: func [ {Converts a number with a negative exponent (E-x) to its decimal bv equivalent. If the number must be converted, then a string will be returned. Otherwise the number sent to the function, N, will simply be returned.} N [number!] "The exponential number to convert." /local ret digit exp _get-dec-exp dec-numbers less-than-zero absn ][ ret: N less-than-zero: either (N < 0) ["-"][""] _get-dec-exp: func [ num [number!] /local shift _exp ][ shift: num _exp: 1 while [shift < 0.1][ shift: shift * 10 ;shifts a number until the fit _exp: _exp + 1 ] return _exp ] absn: abs(N) if (absn // 1 <> 0) [ exp: _get-dec-exp absn if (exp > 1) [ ret: make string! 10 insert/dup ret "0" (exp - 1) ;appends the zeros behind the decimal insert ret (join less-than-zero "0.") dec-numbers: make string! 10 dec-numbers: to-string absn dec-numbers: copy/part (find dec-numbers "E-") at dec-numbers 1 dec-numbers: rejoin parse dec-numbers "." foreach digit dec-numbers [ append ret digit ] ] ] return ret ] ;---------------------------------------------------------------------------

### [11/14] from: chalz:earthlink at: 10-Jan-2003 15:20

My complaint is "Why?" Work-arounds are NOT solutions. It introduces unnecessary complexity. Not to mention that people who are after ultra-optimized code will gripe because it takes extra time, memory and resources to load an additional function. It's not an answer.

### [12/14] from: nitsch-lists:netcologne at: 10-Jan-2003 23:23

if allways two decimal places is ok, you can use to-money. to get rid of the "\$", use next form to-money 123.345 (eventually [copy next ..]) -volker Charles wrote:

### [13/14] from: carl:cybercraft at: 11-Jan-2003 15:37

On 11-Jan-03, Vos, Doug wrote:
> Has everyone who complained tried the function I provided that > solves the problem?
Just tried it on Windows, Amiga and Linux, and while it works as stated on Windows, on Amiga and Linux it gives this error...
>> exp2dec 1E-2
** Script Error: copy expected value argument of type: series port bitset ** Where: exp2dec ** Near: dec-numbers: copy/part (find dec-numbers "E-") at dec-numbers
> It seems to be a good work around for me, so I don't know what > people are still complaining about? Please help me understand...
Does the above help? (: I'm assuming you only tried it on Windows, which shows the problem of trying to write OS work arounds when you don't have all the OSs at your fingertips to test your program on. With REBOL, cross-platform issues need to be solved within REBOL itself, which means it's RT's job. This doesn't mean we shouldn't provide work arounds 'till RT get around to fixing them of course, and I'm sure you can think of a fix for your function, but a real fix needs to be somewhere deep inside REBOL so we don't get these kinds of results... On Windows...
>> 1E-2
== 1E-2 On Amiga and Linux (and many other OSs I assume)...
>> 1E-2