[5.50] FormatNumber() thousands separator

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

[5.50] FormatNumber() thousands separator

Post by Little John »

New function:

Code: Select all

number$ = FormatNumber(Number.d [, NbDecimals [, DecimalPoint$ [, ThousandSeperator$]]])
According to the help, the default character used as thousands separator is a comma ",".
[u]Wikipedia[/u] wrote:Since 2003, the use of spaces as separators (for example: 20 000 and 1 000 000 for "twenty thousand" and "one million") has been officially endorsed by SI/ISO 31-0 standard, as well as by the International Bureau of Weights and Measures and the International Union of Pure and Applied Chemistry, the American Medical Association's widely followed AMA Manual of Style, and the Metrication Board, among others.
Just a small feature request: Please use one space character as default thousands separator.
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: [5.50] FormatNumber() thousands separator

Post by DontTalkToMe »

-1
Comma is the default used by US locale, and BASIC itself use the USA locale for its string formatting functions.
I would prefer to have "," as default as it is now, and also to have a visible char instead of an invisible one.

btw: I wonder why they decided to add this (which is a trivial function you can write by yourself) instead of something along the lines of print using with char masks etc.
At least that could be used for anything, not just numbers, and it's not so trivial to write.
I find this a missed opportunity. :shock:
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: [5.50] FormatNumber() thousands separator

Post by Tenaja »

Little John wrote:Just a small feature request: Please use one space character as default thousands separator.
This does not make sense, because in the US, numbers separated by a space are considered separate, unrelated numbers. It is so engrained that without using either a comma or nothing, even the decimal point of europe is confusing because we do not know if it is referring to a thousand separator or a number less than zero.

Knowing we are not the center of the world, PB has to choose something to standardize on. Perhaps a compiler setting could choose the locale. Otherwise, a consistent location must be chosen for standardization.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: [5.50] FormatNumber() thousands separator

Post by ts-soft »

My wish is, using the local user-system-settings as default, like comma in usa and dot in german for thousands separator,
and comma as DecimalPoint in german, dot in usa.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [5.50] FormatNumber() thousands separator

Post by Little John »

Tenaja wrote:Knowing we are not the center of the world, PB has to choose something to standardize on.
That's right.
And the recommendation of the International Bureau of Weights and Measures (see my first post) seems to be the best choice IMHO.
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: [5.50] FormatNumber() thousands separator

Post by DontTalkToMe »

ts-soft wrote:My wish is, using the local user-system-settings as default, like comma in usa and dot in german for thousands separator,
and comma as DecimalPoint in german, dot in usa.
My suggestion is to leave all as it is now, with "," and "." as defaults, like BASICs already do and expect for VAL(), STR() and similar functions and to implement two native cross platform functions to retrieve the OS specific decimal separator (",") and digit grouping symbol (".") to use where and if required.

Also those functions could be useful well beyond this simple command.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [5.50] FormatNumber() thousands separator

Post by Little John »

DontTalkToMe wrote:My suggestion is to leave all as it is now, with "," and "." as defaults, like BASICs already do and expect for VAL(), STR() and similar functions
Val(), Str(), and similar functions do not handle thousands separators at all.
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: [5.50] FormatNumber() thousands separator

Post by DontTalkToMe »

I know, and it's not relevant to what I said, but thanks anyway. :D

The point was BASICs functions follow the USA locale conventions.

I said my piece, nothing to add. :wink:
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [5.50] FormatNumber() thousands separator

Post by Little John »

DontTalkToMe wrote:I know, and it's not relevant to what I said, but thanks anyway. :D
The problem is: What you said is not relevant to this topic, but thanks anyway. :D
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: [5.50] FormatNumber() thousands separator

Post by DontTalkToMe »

That's your opinion, my suggestions are extremely more useful beyond this specific topic and forward looking then yours, but thanks anyway :lol:
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [5.50] FormatNumber() thousands separator

Post by Little John »

DontTalkToMe wrote:my suggestions are extremely more useful beyond this specific topic and forward looking then yours
Yes of course, there's no doubt about it. You are my hero!
Image
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: [5.50] FormatNumber() thousands separator

Post by DontTalkToMe »

Hope for your sake you are being sincere :mrgreen:
User avatar
TI-994A
Addict
Addict
Posts: 2704
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: [5.50] FormatNumber() thousands separator

Post by TI-994A »

Tenaja wrote:...PB has to choose something to standardize on.
ts-soft wrote:My wish is, using the local user-system-settings as default...
Let's bear in mind that this is simply a convenience function, and not a localisation setting. The team has simply set the period and the comma as the defaults for this new function. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: [5.50] FormatNumber() thousands separator

Post by Dude »

Little John wrote:Please use one space character as default thousands separator.
I say: use what the OS uses. For Windows:

Code: Select all

sep$=Space(9)
GetLocaleInfo_(#LOCALE_USER_DEFAULT,#LOCALE_STHOUSAND,sep$,Len(sep$))
Debug sep$ ; Shows a comma on my English US version of Windows.
Tenaja wrote:PB has to choose something to standardize on.
I agree, which is why it should use the default OS thousands separator, as I just mentioned. Makes perfect sense and stops any arguing. ;)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: [5.50] FormatNumber() thousands separator

Post by ts-soft »

@Dude

+1 (it is the same as what i say with my thread)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply