Negative Numbers and NumberFormat

Paul Dupuis paul at researchware.com
Wed Apr 5 20:27:28 EDT 2017


On 4/5/2017 7:42 PM, J. Landman Gay via use-livecode wrote:
> On 4/5/17 5:48 PM, Richard Gaskin via use-livecode wrote:
>> Jacque wrote:
>>
>>> HyperCard distinguished between "#" and "0" and produced different
>>> results. It sounds like LC doesn't?
>>
>> Confirmed - running this script in v9dp6 and again all the way back in
>> v6.0:
>>
>> on mouseUp
>>    set the numberformat to "###.###"
>>    put 2.5 + 2.5 into x
>>    set the numberformat to "000.000"
>>    put 2.5 + 2.5 into y
>>    put x &cr& y
>> end mouseUp
>>
>> ...I get:
>>
>> 005.000
>> 005.000

NumberFormat on applies when the number is output or forced to convert
to a string (for example when doing string concatenation). The variant
script below:

on mouseUp
   set the numberformat to "###.###"
   put 2.5 + 2.5 into x
   put x & cr after msg
   set the numberformat to "000.000"
   put 2.5 + 2.5 into y
   put y &cr after msg
end mouseUp

results in:

005
005.000

In the message box. Just another data point for the discussion.







More information about the use-livecode mailing list