.toExponential behavior

Nov 2, 2010 at 7:13 AM

Hi,

There seems to be an somewhat odd behavior which I believe is a bug.
If one uses parseFloat to convert a string number into a var and then tries to use toExponential it will not work.

Some sample code from my colleague that shows the problem below.

Or are we misunderstanding something?

Ps. Echo is just a C# method that will output the string to a log view.

// Example that shows on odd behaviour of output from parseFloat()
// where .toExponential can't be used.

var
 someNumber ;

someNumberString =
"123.456789012" ;
Echo
( "someNumber = "   +  someNumberString );
Echo
( "typeof someNumber = "   +   typeof  someNumberString );
Echo
( "##" );

someNumber = parseFloat
( someNumberString );
Echo
( "someNumber = "   +  someNumber );
Echo
( "typeof someNumber = "   +   typeof  someNumber );
// This fails with Error "JintException: Object expected: toExponential"

Echo
( "someNumber exp = "   +  someNumber . toExponential ( 6 ));
Echo
( "##" );

// But after we add 0.0 to the output from parseFloat we can use the .toExponential() function

someNumber = parseFloat
( someNumberString )   +   0.0 ;
Echo
( "someNumber exp = "   +  someNumber . toExponential ( 6 ));
Echo
( "typeof someNumber = "   +   typeof  someNumber );

Coordinator
Nov 3, 2010 at 7:59 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.