Negative Numbers and NumberFormat

Mark Waddingham mark at livecode.com
Wed Apr 5 14:56:40 EDT 2017


On 2017-04-05 20:28, Bob Sneidar via use-livecode wrote:
> And here is an oddity again. In the dictionary, there is no mention of
> spaces or any other character besides "0.#" being valid in a
> numberformat string, but:
> 
> set the numberformat to " 00";put -09+0 & ":" & 00+0 & ":" & 00+0
> 
> produces -09:000:000
> 
> In fact, you can put ANYTHING in place of a 0, and it will treat it as
> though it were a 0!
> 
> Whaaaaa???

I think the numberFormat is perhaps just appearing to do more than it 
actually does. Basically it allows you to set the field width before and 
after a decimal point. So:

   set the numberFormat to "<N anything>.<M anything>"

Will result in the engine padding either side of the decimal point up to 
the specified number of chars with 0 if the length of that part is less 
than the specified width.

Whether or not the '-' sign should be included in these width 
calculations I guess is a matter of debate...

Warmest Regards,

Mark.

P.S. Apologies for missing your actual point before, I should have read 
the thread in more detail before posting ;)

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list