Negative Numbers and NumberFormat

Bob Sneidar bobsneidar at iotecdigital.com
Wed Apr 5 12:26:58 EDT 2017


<sigh> Never mind. 

Bob S


> On Apr 4, 2017, at 13:12 , hh via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
>>>> Bob S. wrote:
>>>> You should rather say the number format determines the num of DIGITS. 
>>> hh wrote: 
>>> That's what you wish to have (good idea). But it's not like that, its 
>>> the length of the number as string. 
>> Bob S. wrote
>> Really? Then why does :
>> set the numberformat to 0.0; put -.1 + 0 result in -0.1 ?  
> 
> You are mixing input methods and output methods.
> 
> "-.x" (or ".x") is allowed as input, but then converted to
> "-0.x" (or "0.x"). Just the same for "00.x" or "-00.x"
> 
> *After* that the numberformat is applied (and doesn't cut if leading is
> longer). That's why
> 
>  set the numberformat to "0.0"
>  put 0-".1", 0+"-0.1", 0+"-00.1" after s -- you may leave out quotes
>  set the numberformat to "00.0"
>  put 0-".1", 0+"-0.1", 0+"-00.1" after s -- you may leave out quotes
> 
> both yield -0.1,-0.1,-0.1 (in LC 6/7/8/9).
> 
> To see more clear the string length is applied to the number:
> You can use _ANY_ other one-byte-char other than the separator (".").
> 
> set the numberformat to "ab.c"
> is equivalent to
> set the numberformat to "00.0"
> 
> This is comfortable if you wish to have the numbers length
> dependent on any string varibale's length:
> 
>  put "Bob.S" into str
>  set the numberformat to str
>  put 0-12 & " _and_ " & 0+13
> 
> yields -12.0 _and_ 013.0, as I said (in LC 6/7/8/9).
> 
> *** Once again, I like and support your idea. ***
> But I suggest to name it a feature request, not a bug:
> 
> Perhaps the option to apply the numberformat to the absolute value
> only and choose/apply a prefix: either +, -, space or empty?
> The empty is for people who distinguish negative and positive nums
> by labels only (debit and credit) or colors only (red and black).
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list