Code: Select all
1_000_000
0.103_850
$6B_C7_5E_2D_63_10_00_00
%1111_0100_0010_0100_000_0
Code: Select all
1_000_000
0.103_850
$6B_C7_5E_2D_63_10_00_00
%1111_0100_0010_0100_000_0
Code: Select all
; Input
A$ = "1_000_000"
Debug A$
A = Val(ReplaceString(A$, "_", ""))
Debug A
; Output
Debug FormatNumber(1000000, 0, "", "_")
Code: Select all
1_000_000
1000000
1_000_000
The advantage is to make it instant to tell if you are writing 10000000 or 10000000. Or, rather, 10,000,000 vs 100,000,000. Without them, you have to count the digits. With them, it's an instant glance.BarryG wrote:Why on earth would you want to write numbers like that? What's the advantage?
I do not believe the syntax checker would be slowed down noticeably. You would only be adding one character to a number checker, which already permits at least 17. (0-9, A-F, and decimal) Adding the underscore will be trivial, and scanned just like the decimal. As for bugs, it would not increase them unless you are trying to convert to a new language, and that's going to require bugchecking anyway.Tough call. Comparing C libs and other code without '_'s would be a nightmare.
And this opens the door for many bugs.
As well as slowing down the syntax checker.
What if a macro inserts an underscore and gets interpreted as a number?
Oh, I misunderstood. I thought they were like Data or something, rather than a single number on each example.Tenaja wrote:The advantage is to make it instant to tell if you are writing 10000000 or 10000000. Or, rather, 10,000,000 vs 100,000,000. Without them, you have to count the digits. With them, it's an instant glance.
Code: Select all
#n_10_mill=10000000
#n_100_mill=100000000
I don't see a problem. The underscore is removed during compilation, so there is no difference between the number literals 1_000 and 1000. It is a syntax supported by new programming languages (for example Rust and Nim).skywalk wrote:Tough call. Comparing C libs and other code without '_'s would be a nightmare.
And this opens the door for many bugs.
As well as slowing down the syntax checker.
What if a macro inserts an underscore and gets interpreted as a number?
I find a symbol better than syntax coloring in that case. There are already many token types that can be colored and even more colors will not improve the readability of the code, but worsen it.BarryG wrote:Thought: Rather than changing the compiler to deal with it, maybe the IDE could syntax-color the numbers instead, with slightly darker/lighter characters with each thousands section?
Sure, for many things own solutions can be developed. The problem is that then everyone also has to set up the special solution to be able to use the codes, which could certainly be too cumbersome for some.BarryG wrote:At any rate, a pre-compiler tool could also easily do what Sicro wants.
BarryG wrote:Or use constants if you're going to use such large numbers, so it's easier to read in your code:
Code: Select all
#n_10_mill=10000000 #n_100_mill=100000000
Code: Select all
; this:
#N_Thousands = 1000
a = 5 * #N_Thousands + 155
; against:
b = 5'155
; or
c = 5_155
I also agree with this variant. The apostrophe is not yet used in the PureBasic language, unlike the underscore, so it would probably be more suitable.Josh wrote:1'000'000.00
I would prefer a single quote, as it is/was also used on pocket calculators. There should not be any conflicts with it.
Yes it is, to convert literal characters to their ASCII value:Sicro wrote:The apostrophe is not yet used in the PureBasic language
Code: Select all
For c = 'A' To 'Z'
Debug Chr(c)
Next
Feature request posted here -> viewtopic.php?f=18&t=76794Tenaja wrote:The advantage is to make it instant to tell if you are writing 10000000 or 10000000. Or, rather, 10,000,000 vs 100,000,000. Without them, you have to count the digits. With them, it's an instant glance.
Fred's not the type to break 20 years of code to force a feature request on everyone. Typically he makes new features like this optional.skywalk wrote:We already have X = 1e3 ; 1000
Or X = 1e9; 1,000,000,000
Kill me if I have to type a google zero's with '_'s.
+1 me too. An ide edit would require double clicking, which wouldn't likely be easier (for Fred) and wouldn't be as user friendly.#NULL wrote:+1