EmbeddedRelated.com
Forums
The 2026 Embedded Online Conference

Decimal Point vs. Decimal Comma

Started by rickman April 2, 2016
I know that roughly half the world uses a period to separate the 
fractional part of a number from the integer part.  Roughly half the 
world uses a comma for the same purpose.  But what about in computer 
languages?  A little research showed that Algol was specified to work 
with either.  Other computer languages seem to work primarily or 
exclusively with a period (point).

Are there any languages that support both formats without special 
programming?

-- 

Rick
rickman <gnuarm@gmail.com> writes:
>I know that roughly half the world uses a period to separate the >fractional part of a number from the integer part. Roughly half the >world uses a comma for the same purpose. But what about in computer >languages? A little research showed that Algol was specified to work >with either.
Not really. Algol 60 (not sure about 68) did not specify the concrete representation of the lexemes. So one compiler could accept 123.45 and a different compiler could accept 123,45 as concrete syntax of the same number. But the compilers would not necessarily accept the other syntax. A typical standardization cockup.
>Are there any languages that support both formats without special >programming?
Some Forth implementations do. E.g., SwiftForth and bigForth: ANS bigFORTH 386-Linux rev. 2.3.1 123.45 d. 12345 ok 123,45 d. 12345 ok A very early version of Gforth also worked that way, but I removed this feature, because it's more important to be able to get a useful error message if you use "2,", but the Forth system does not define it. I have not missed this feature, and I come from the part of the world that uses decimal comma. - anton -- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html New standard: http://www.forth200x.org/forth200x.html EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/
On Sat, 2 Apr 2016 17:49:07 -0400, rickman <gnuarm@gmail.com> wrote:

>I know that roughly half the world uses a period to separate the >fractional part of a number from the integer part. Roughly half the >world uses a comma for the same purpose. But what about in computer >languages? A little research showed that Algol was specified to work >with either. Other computer languages seem to work primarily or >exclusively with a period (point). > >Are there any languages that support both formats without special >programming?
In COBOL: DECIMAL-POINT IS COMMA
On 4/3/2016 2:23 AM, Anton Ertl wrote:
> rickman <gnuarm@gmail.com> writes: >> I know that roughly half the world uses a period to separate the >> fractional part of a number from the integer part. Roughly half the >> world uses a comma for the same purpose. But what about in computer >> languages? A little research showed that Algol was specified to work >> with either. > > Not really. Algol 60 (not sure about 68) did not specify the concrete > representation of the lexemes. So one compiler could accept 123.45 > and a different compiler could accept 123,45 as concrete syntax of the > same number. But the compilers would not necessarily accept the other > syntax. A typical standardization cockup. > >> Are there any languages that support both formats without special >> programming? > > Some Forth implementations do. E.g., SwiftForth and bigForth: > > ANS bigFORTH 386-Linux rev. 2.3.1 > > 123.45 d. 12345 ok > 123,45 d. 12345 ok > > A very early version of Gforth also worked that way, but I removed > this feature, because it's more important to be able to get a useful > error message if you use "2,", but the Forth system does not define > it. I have not missed this feature, and I come from the part of the > world that uses decimal comma.
But neither of these are "correct". I was talking about the radix point that separates the fraction from the integer portion of a number. -- Rick
On 4/3/2016 2:23 AM, Anton Ertl wrote:
> rickman <gnuarm@gmail.com> writes: >> I know that roughly half the world uses a period to separate the >> fractional part of a number from the integer part. Roughly half the >> world uses a comma for the same purpose. But what about in computer >> languages? A little research showed that Algol was specified to work >> with either. > > Not really. Algol 60 (not sure about 68) did not specify the concrete > representation of the lexemes. So one compiler could accept 123.45 > and a different compiler could accept 123,45 as concrete syntax of the > same number. But the compilers would not necessarily accept the other > syntax. A typical standardization cockup. > >> Are there any languages that support both formats without special >> programming? > > Some Forth implementations do. E.g., SwiftForth and bigForth: > > ANS bigFORTH 386-Linux rev. 2.3.1 > > 123.45 d. 12345 ok > 123,45 d. 12345 ok > > A very early version of Gforth also worked that way, but I removed > this feature, because it's more important to be able to get a useful > error message if you use "2,", but the Forth system does not define > it. I have not missed this feature, and I come from the part of the > world that uses decimal comma.
But neither of these are "correct". I was talking about the radix point that separates the fraction from the integer portion of a number. -- Rick
In comp.arch.embedded rickman <gnuarm@gmail.com> wrote:
> Are there any languages that support both formats without special > programming?
ENVIRONMENT DIVISION. CONFIGURATION SECTION. DECIMAL-POINT IS COMMA. COBOL :) -- Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org
On Sat, 2 Apr 2016 17:49:07 -0400, rickman <gnuarm@gmail.com> wrote:

>I know that roughly half the world uses a period to separate the >fractional part of a number from the integer part. Roughly half the >world uses a comma for the same purpose. But what about in computer >languages? A little research showed that Algol was specified to work >with either. Other computer languages seem to work primarily or >exclusively with a period (point). > >Are there any languages that support both formats without special >programming?
If I understand correctly that you're asking about numeric literals in program source, then I think the answer is COBOL and very possibly nothing else. It's trivial to make a lexer accept either number format, but many languages use commas as separators for, e.g., function arguments, array and list elements, etc. ... so also using commas as decimal marks would cause problems. Consider: x = f( 1,9 ); Is that one argument or two? Depends on number lexing. Given a particular lexing, one of the two possible parses is an error - but which depends on the declaration of f(). This could be extremely confusing to a programmer. The only way around it is to also change the argument separator, or to enforce that truly separate values be separated by whitespace in addition to the separator. Pretty much only the whitespace separated sexpr syntax of Lisp (and Scheme) is immune to the parsing issue ... languages like ML and Haskel, etc. don't necessarily need commas for function calls, but they still do use them for other things. I'm not aware of any language that specifically addresses this issue regarding its source code - all that I am familar with simply use the dot syntax for decimals. Number formats often are addressed as locale issues for I/O libraries, but not for program source. Many compilers now allow Unicode in their source, but programmers still are actively discouraged from using non-ASCII characters. And non-English speaking programmers almost are forced to program in English for portability. English is the lingua franca of programming. There have been compilers designed specifically for certain locales, but sans government mandate of their use, none has ever been very successful. Incidentally, I'm not sure what you saw re: Algol, but neither Algol 60 nor 68 permitted commas as decimal marks - both used the dot syntax. I don't have a reference for Algol 58, but all the Algols used commas as argument and array separators, so they all would have been susceptible to the parsing issue described above. YMMV, George
rickman wrote:
> I know that roughly half the world uses a period to separate the > fractional part of a number from the integer part. Roughly half the > world uses a comma for the same purpose. But what about in computer > languages? A little research showed that Algol was specified to work > with either. Other computer languages seem to work primarily or > exclusively with a period (point). > > Are there any languages that support both formats without special > programming? >
Maybe by modfying the read-table of Common Lisp. But this might already be "special programming" and I don't even know exactly if this is possible (but I very much suppose so). http://clhs.lisp.se/Body/02_.htm --> http://clhs.lisp.se/Body/02_aa.htm
Am 02.04.2016 um 23:49 schrieb rickman:
> I know that roughly half the world uses a period to separate the > fractional part of a number from the integer part. Roughly half the > world uses a comma for the same purpose. But what about in computer > languages?
In computer languages we have barely enough punctuation letters available as it is, to express all the necessary things without being overly verbose. Wasting one on a luxury item like that would IMHO be unjustifiable. Programs need to be able to handle localized formats on input and output, but not in the source itself.
On Sun, 3 Apr 2016 14:18:56 +0200, Hans-Bernhard Br&#4294967295;ker
<HBBroeker@t-online.de> wrote:

>Am 02.04.2016 um 23:49 schrieb rickman: >> I know that roughly half the world uses a period to separate the >> fractional part of a number from the integer part. Roughly half the >> world uses a comma for the same purpose. But what about in computer >> languages? > >In computer languages we have barely enough punctuation letters >available as it is, to express all the necessary things without being >overly verbose. Wasting one on a luxury item like that would IMHO be >unjustifiable.
Some computer languages like COBOL and FORTRAN could be written with 6 bit codes (like FIELDDATA). Unfortunately languages like C and Pascal used characters from ISO-686 character sets, including characters reserved for national variants.
>Programs need to be able to handle localized formats on input and >output, but not in the source itself.
What is the problem of using Latin-1 (ISO 8859-1) in a programming language ? In fact it would be a great thing, if you could use UTF-8 in programming, e.g. Greek letters Alfa and Beta as program variables ? No need to do any translitteration from any textbok variables.
The 2026 Embedded Online Conference