Page 1 of 2

Comma's in numbers.

Posted: Sun Sep 08, 2013 8:34 am
by Opcode
Pretty self explanatory here. I am sure it wouldn't take much for the compiler to just ignore them. It's just too easy to get larger numbers like exampled below mixed up.

Code: Select all

100000000 -> 100,000,000
Of course you'd probably have to remove it from the line continuation feature.

Re: Comma's in numbers.

Posted: Sun Sep 08, 2013 9:37 am
by STARGĂ…TE
:shock:

The comma is the separator for parameters in procedures!
What does the compiler in your idea here:

Code: Select all

Procedure Test(a, b=0)
	Debug a
	Debug b
EndProcedure

Test(123,456)
is 123,456 a whole number? Or Parameter for a and b?

Re: Comma's in numbers.

Posted: Sun Sep 08, 2013 10:45 am
by PB
No programming language in the history of the world has ever had commas for numbers,
probably because commas aren't used to separate numbers in all languages worldwide.
Some use periods, some just dots, some use apostrophes, and some just use spaces.
And China separates every 4 digits, not every 3. Here's some information about it:

http://www.statisticalconsultants.co.nz ... /WF31.html

If you want something easier on your eyes for large numbers, why not help yourself?

Code: Select all

Procedure EZ(num$)
  ProcedureReturn ValD(RemoveString(num$,","))
EndProcedure

; Add 100000000 and 222222222 together:
Debug EZ("100,000,000")+EZ("222,222,222")

Re: Comma's in numbers.

Posted: Sun Sep 08, 2013 1:48 pm
by Tenaja
PB wrote:

Code: Select all

Procedure EZ(num$)
  ProcedureReturn ValD(RemoveString(num$,","))
EndProcedure

; Add 100000000 and 222222222 together:
Debug EZ("100,000,000")+EZ("222,222,222")
Wow, talk about code bloat! Might work for an "occasional" number, but I certainly would not use that for numerous numbers.

Anyway, I have a compiler (not for PCs) that allows the underscore anywhere in the middle of a number. Comes in handy for binary, that's for sure. Syntactically, it works because the only other time an underscore can be next to a digit is if both are part of the same identifier name.

Re: Comma's in numbers.

Posted: Sun Sep 08, 2013 1:59 pm
by luis
Tenaja wrote: Anyway, I have a compiler (not for PCs) that allows the underscore anywhere in the middle of a number.
HLA (high level assembly) does that.
The ability to space out big decimal numbers, or the byte/words components in binary and hex numbers is really helpful.
If I ever had to write a language I would put this feature in it for sure :)

Re: Comma's in numbers.

Posted: Sun Sep 08, 2013 2:33 pm
by PB
> Wow, talk about code bloat!

Actually, that sort of "bloated" code is needed any time that you
need to convert "normal" numbers to plain. Say you have a finance
app that needs to convert a table of numbers like "$1,234,567.00"
to just 1234567... how are you going to do it without a procedure?

Re: Comma's in numbers.

Posted: Sun Sep 08, 2013 2:39 pm
by Little John
luis wrote:
Tenaja wrote: Anyway, I have a compiler (not for PCs) that allows the underscore anywhere in the middle of a number.
HLA (high level assembly) does that.
Euphoria 4.x ( which is a Basic-like programming language, not a drug :-) ) allows it as well.
luis wrote:The ability to space out big decimal numbers, or the byte/words components in binary and hex numbers is really helpful.
Agreed.

Re: Comma's in numbers.

Posted: Sun Sep 08, 2013 3:46 pm
by Korolev Michael
May be there is a way to do something like popping tool tip? Like this:

Image

Re: Comma's in numbers.

Posted: Mon Sep 09, 2013 10:59 am
by PB
That's a nice idea, Michael; but which character are you going to use?
As I showed above, commas aren't used in every language of the world.

Re: Comma's in numbers.

Posted: Mon Sep 09, 2013 11:17 am
by Danilo
PB wrote:That's a nice idea, Michael; but which character are you going to use?
As I showed above, commas aren't used in every language of the world.
Underscore '_' is a good idea. Because numbers can't contain it. If a number is started (at parsing), ignoring any underscores would be possible.

Re: Comma's in numbers.

Posted: Mon Sep 09, 2013 11:20 am
by PB
I'd prefer no numbers be touched, anyway. Are we coders or not?

Re: Comma's in numbers.

Posted: Mon Sep 09, 2013 11:27 am
by Danilo
PB wrote:I'd prefer no numbers be touched, anyway. Are we coders or not?
So you meant locale system setting for a tooltip? 1,000,000 or 1.000.000?

Thought you meant code like: x = 1_000_000
because it should be possible from a point of a language parser.

Thing is, PB is fixed to english notation. It already uses points '.' for floats,
whereas a german parser would use comma ',' for floats. International users
are used to the english notation, so no problem (If, While, Repeat, Until, ...everything English anyway).
PB uses english syntax, and ignoring underscore in numbers should be possible.
So 1_000_000 becomes 1000000, and 1_0_0_0 becomes 1000.

Re: Comma's in numbers.

Posted: Mon Sep 09, 2013 11:41 am
by freak
Just use a macro:

Code: Select all

Macro Num(a=,b=,c=,d=,e=,f=)
  a#b#c#d#e#f
EndMacro


Debug Num(1,000)
Debug Num(1,000,000)

Re: Comma's in numbers.

Posted: Mon Sep 09, 2013 11:46 am
by Danilo
freak wrote:Just use a macro:

Code: Select all

Macro Num(a=,b=,c=,d=,e=,f=)
  a#b#c#d#e#f
EndMacro


Debug Num(1,000)
Debug Num(1,000,000)
Nice idea, if you want to use comma ',' as thousands separator (english notation).

Re: Comma's in numbers.

Posted: Mon Sep 16, 2013 5:26 pm
by blueznl
Well, we're supposed to use the 100.000.000,00 notation here in NL, and I hate it!

But to be honest, I would have no problem with the 100_000_000.00 variant. Not that I need it though, it just wouldn't bother me 8)