Quantcast

Negative Numbers and NumberFormat

classic Classic list List threaded Threaded
29 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Negative Numbers and NumberFormat

prothero--- via use-livecode
Was anyone aware that the sign takes up one of the digital in number format? For instance,

set the numberformat to "00";put -1 +0 & ":" & 0 +0 & ":" & 0 +0
returns:
-1:00:00

but
set the numberformat to "00";put -12 +0 & ":" & 0 +0 & ":" & 0 +0
returns:
-12:00:00

Does no one else find that odd??

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

dunbarx
Hi.

Hmmm.

When you say "...the sign takes up one of the digital " does this make it better or worse:

   set the numberformat to "00"
   put -1112 +0 & ":" & 0 +0 & ":" & 0 +0

or going the other way, with your top snippet, did you expect:

-01:00:00

Craig Newman
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
Yes I expected this. It's not that I cannot work around it, it's just that it seems it ought to put 2 zeros where 2 zeros are specified in the numberFormat and if it doesn't and should, then I will file an (admittedly low priority) bug report.

Bob S


> On Apr 3, 2017, at 10:16 , dunbarx via use-livecode <[hidden email]> wrote:
>
> -01:00:00
>
> Craig Newman


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
In reply to this post by prothero--- via use-livecode
TMHO, this could be a feature request rather than a bug report.
The zeros in the number format determine the num of characters
and "-" is one.

Also we have -0 = 0. So what about "-01:-00:-00" ??

> Bob S. wrote:
> "-01:00:00"?
> Yes I expected this. It's not that I cannot work around it,
> it's just that it seems it ought to put 2 zeros where 2 zeros
> are specified in the numberFormat and if it doesn't and should,
> then I will file an (admittedly low priority) bug report.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
The time format is irrelevant. It just so happens I have a function for calculating the difference in time, and when the first character is a - I know the end time is earlier than the start time, which was what I was checking for.

And I think you are mistaken. numberFormat sets the format for numeric values, not just any characters. You should rather say the number format determine the num of DIGITS. Signage is an acceptable part of a numeric value. A dollar sign or a comma for example are not.

Still, if everyone expects that set the number format to "00"; return 0-1 should return -1, well then that's how it should be.

Bob S


> On Apr 3, 2017, at 15:49 , hh via use-livecode <[hidden email]> wrote:
>
> TMHO, this could be a feature request rather than a bug report.
> The zeros in the number format determine the num of characters
> and "-" is one.
>
> Also we have -0 = 0. So what about "-01:-00:-00" ??


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
In reply to this post by prothero--- via use-livecode
> Bob S. worte:
> I have a function for calculating the difference in time

Then you mean -(01:00:00) and not (-01):(00):(00), quite different.

AFAIK most languages do such time evaluations as follows
1) compute the time in seconds,
2) convert its absolute value to time format, and
3) if negative, put "-" before the formatted time.
That is, the whole display is not an immediate result of setting the
number format.

> You should rather say the number format determines the num of DIGITS.

That's what you wish to have (good idea). But it's not like that, its
the length of the number as string. You gave the proof yourself.
It's the same with the number formats from format(). Probably LC uses
internally format() for its numberFormat.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
Really? Then why does :
set the numberformat to 0.0;put -.1 + 0
result in
-0.1

?

Bob S


> On Apr 3, 2017, at 16:55 , hh via use-livecode <[hidden email]> wrote:
>
>> You should rather say the number format determines the num of DIGITS.
>
> That's what you wish to have (good idea). But it's not like that, its
> the length of the number as string.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
In reply to this post by prothero--- via use-livecode
>>> 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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
<sigh> Never mind.

Bob S


> On Apr 4, 2017, at 13:12 , hh via use-livecode <[hidden email]> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
In reply to this post by prothero--- via use-livecode
On 2017-04-03 19:11, Bob Sneidar via use-livecode wrote:

> Was anyone aware that the sign takes up one of the digital in number
> format? For instance,
>
> set the numberformat to "00";put -1 +0 & ":" & 0 +0 & ":" & 0 +0
> returns:
> -1:00:00
>
> but
> set the numberformat to "00";put -12 +0 & ":" & 0 +0 & ":" & 0 +0
> returns:
> -12:00:00
>
> Does no one else find that odd??

It looks odd, but is explainable. It has nothing to do with '-' eating
up
places for 0 in the numberFormat, but to do with the type of things in
that expression:

Contrast:

set the numberformat to "00";put 0+0 & ":" & 0+0 & ":" & 0+0
   => 00:00:00

And:

set the numberformat to "00";put 0 & ":" & 0 & ":" & 0
   => 0:0:0

The reason here is that the token 0 in a script is actually treated as a
string *until*
you do something to it which turns it into a number. Only numbers are
subject to
numberFormat.

So, in the first case you are doing:

   put NUMBER & ":" & NUMBER & ":" & NUMBER

In the second case you are doing:

   put STRING & ":" & STRING & ":" & STRING

The & operator requires two strings, so in the first case the NUMBERs
are being
converted to strings (and thus subject to numberFormat) whereas in the
second
case they are already STRINGs so no conversion takes place.

I class this as an anomaly.

The correction would be that any token in script which *looks* like a
number should
act like a number in terms of string conversion rules (including the
application of
numberFormat), even if it can't be represented exactly as a number.

This rule would mean that as long as you don't attempt to do arithmetic
on something
which looks like a number, how it looks will be preserved.

The latter bit about 'not being able to do arithmetic' might sound odd
but it is
a reflection of the finiteness of computers.

For example, the engine currently uses IEEE doubles for all its
arithmetic. Whilst
such things can represent a very large number of numbers (2^60 different
values or
near enough), the actual range a double can represent is substantially
bigger (many
orders of magnitude bigger, in fact - something like -10^300 to
+10^300). This results
in there being many many string representations which map to the same
double (for example
0 can be written as 0, 0.0, 0.00, 0.000, ...).

Indeed, doubles only have about 15 digits of decimal precision, meaning
that if your
actual number has more than 15 non-zero digits before or after a lot of
0's then
you'll get an approximation to the actual number (well, you'll get a
number which is
within DBL_EPSILON of the real number, anyway - this kind of stuff gets
pernickety very
very quickly).

In actual fact, the above rule can be extended further - and perhaps
expressed more
succinctly as:

   If a string is converted to a number, then the actual conversion
should not
   occur until it is absolutely needed.

The point here is that formatting a (decimal) string representation of a
number
via numberFormat does not actually require conversion to an actual
number - it can
be done using the string representation alone - and doing it that way
would mean
that numbers would be preserved to look exactly as they did unless you
actual poke
them with arithmetic.

Of course, you might argue that 'whats the point of numbers if you don't
do
arithmetic on them' - but it is often the case that our programs
manipulate
numbers without doing anything to them, we just need to know that 'they
are
numbers'.

A good example is the json importers/exporters which exist. They do
zero arithmetic - they merely import and export existing data. In that
case it
is very important that the data is preserved *as is* otherwise you can't
roundtrip
(i.e. import data, and immediately export without changing anything).

Warmest Regards,

Mark.

--
Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
LiveCode: Everyone can create apps


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
On 2017-04-05 19:21, Mark Waddingham via use-livecode wrote:
> The latter bit about 'not being able to do arithmetic' might sound odd
> but it is
> a reflection of the finiteness of computers.

Just correcting myself: 'finiteness of computers' was the wrong thing to
say
here - if you can represent a number as a decimal string in a computer
then it
is clearly finite as the amount of memory you have is finite.

Therefore, it is more about 'needing to do arithmetic quickly on
computers'
(for some definition of 'quickly').

Mark.

--
Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
In reply to this post by prothero--- via use-livecode
That was my point, that the sign should not take up one of the digits in numberformat 00. And thank you for your explanation about strings being strings until math was done on them. In my timeCalc() function however, I already convery everything to seconds and just before conatenating HH, MM and SS, I add 0 to each one.

set the numberformat to "00"
return tTotalHours +0 & ":" & tTotalMinutes +0 & ":" & tTotalSeconds +0

If tTotalHours is negative I get -H if it is less than 10. Like I said it's not a big deal. I can always work around it.

Bob S


> On Apr 5, 2017, at 10:21 , Mark Waddingham via use-livecode <[hidden email]> wrote:
>
> It looks odd, but is explainable. It has nothing to do with '-' eating up
> places for 0 in the numberFormat, but to do with the type of things in
> that expression:


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
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???

Bob S



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
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 ~ [hidden email] ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
I should say the bit of engine code which does parsing and application of the numberformat has been left untouched in terms of what it does for as long as I can remember... It is one of those places where a subtle change could break apps quite easily as it is somewhat hard to see precisely what it should and should not do!

Mark

Sent from my iPhone

> On 5 Apr 2017, at 19:56, Mark Waddingham via use-livecode <[hidden email]> wrote:
>
>> 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 ~ [hidden email] ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
Yup. I have thought for a long time that there should be a formatNumber() function that did almost exactly what Excel does in terms of formatting a number. I will have to look into that. I'll post it if I throw one together. Should be easy given the string operations LC is capable of.

Bob S


On Apr 5, 2017, at 12:07 , Mark Waddingham via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

I should say the bit of engine code which does parsing and application of the numberformat has been left untouched in terms of what it does for as long as I can remember... It is one of those places where a subtle change could break apps quite easily as it is somewhat hard to see precisely what it should and should not do!

Mark

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
In reply to this post by prothero--- via use-livecode
On 4/5/17 2:07 PM, Mark Waddingham via use-livecode wrote:
> I should say the bit of engine code which does parsing and
> application of the numberformat has been left untouched in terms of
> what it does for as long as I can remember... It is one of those
> places where a subtle change could break apps quite easily as it is
> somewhat hard to see precisely what it should and should not do!

HyperCard distinguished between "#" and "0" and produced different
results. It sounds like LC doesn't?

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
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

Where I would have expected:

5.0
005.000

Who wants to file the bug report?

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
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
>
> Where I would have expected:
>
> 5.0
> 005.000
>
> Who wants to file the bug report?
>

The fact that the dictionary also doesn't discriminate implies it isn't
a bug, it's intentional, and the hash/zero options are for HC
compatibility only. I can't remember if MC worked as I would have expected.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Negative Numbers and NumberFormat

prothero--- via use-livecode
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.




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
12
Loading...