Having problems with numberformat....

David Bovill david at openpartnership.net
Thu Nov 2 17:17:54 EST 2006


Hi Dar!

On 01/11/06, Dar Scott <dsc at swcp.com> wrote:
>
>
> By the way, the numberFormat setting is not needed for a level of
> arithmetic accuracy.  The result of arithmetic is always about 15
> digits.  The numberFormat comes into play the first time the result
> of arithmetic is used as text.


OK

The result of arithmetic will also pass as parameters just fine
> (though converted to text with numberFormat coming into play when
> passed using send).


Great

Literals do not need the zeros out to 12 places.
>
> So numberFormat is not used until the final result is put into the
> message box.  This should generate the same result:
>
> on mouseDoubleUp
>    put 0.006911491563 into projectedWidth
>    get -1 * projectedWidth
>    set the numberformat to "#.000000000000"
>    put it
> end mouseDoubleUp


This is not working. Not in a fresh button in a new stack and AFAIK nothing
to do with any libraries (I am using OSX 10.4.8 and Rev 2.7.4). In
otherwords the output of this script is:

  -0.006911

and not:

  -0.006911491563

I can get around it by adding and empty space as in the following script:

on mouseUp
    put 0.006911491563 into projectedWidth
    get -1 * projectedWidth
    set the numberformat to "#.000000000000"
    put it & empty
end mouseUp

which outputs:

    -0.006911491563

In previous versions ading zero to the number had the effect of forcing the
number to be formatted. Now as you state this only happens when treating the
number as a string - ie putting it into a field or doing a string
maniplulation. As I am sending it to another application using AppleScript -
I got caught. I think this is a bug - no?



More information about the use-livecode mailing list