Re: Gentler Decimal Floating-Point
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Thu, 29 Mar 2007 10:40:58 -0800
Quadibloc wrote:
(snip)
I've heard of that characteristic of PL/I - that binary constants have
to be *written* in binary. I consider that to be utterly bizarre.
Binary numbers inside the computer are still made to represent
numbers, so of course they will be written *in programs* in decimal.
Except for DEC assemblers which seem to prefer octal, it is
usual even for assembly code for the default to be decimal.
For PL/I I was never sure if the intent was to specify the
desired range in decimal, or really to specify decimal arithmetic.
Consider that the Fortran SELECTED_REAL_KIND and SELECTED_INT_KIND
specify the precision and range in decimal digits independent
of the base (any base greater than one) in use.
One possibility is that the PL/I DECIMAL specifier indicates
that the range, precision, or scale factor is specified in decimal
digits. For fixed point with non-zero scale factor that will result
in a lot of multiply and divide by powers of ten, somewhat easier
to do in decimal arithmetic. For FLOAT DECIMAL until recently it
looks like IBM has considered it a way to specify the desired
precision in decimal digits for binary arithmetic.
PL/I was supposed to be usable as a replacement for both FORTRAN and
COBOL, but this one thing is enough to throw out its usability as a
FORTRAN replacement. (Although, I suppose if no implementations are
insane enough to convert from decimal to binary at run time, it could
be tolerated, but it still has a vast potential to create pitfalls.
Yes, I believe compilers are expected to convert constants at compile
time. The language rules specify how those conversions are to be
done. Overall the rules seem to make sense, though in some specific
cases they seem wrong.
> Although I thought this applied only to fixed-point binary and
> decimal, float only existing as binary, at least on System/360 at that
> time.)
Yes. FLOAT DECIMAL could be considered a way to specify the desired
precision in decimal digits, not a request for actual decimal
arithmetic. It does seem convenient to be able to specify the
range or precision actually needed in a given calculation,
instead of depending and/or hoping that the processor defaults
are good enough. In most cases one doesn't really know so
precisely how many digits they need, so popular defaults are used.
-- glen
.
- Follow-Ups:
- Re: Gentler Decimal Floating-Point
- From: Mike Cowlishaw
- Re: Gentler Decimal Floating-Point
- References:
- Gentler Decimal Floating-Point
- From: Quadibloc
- Re: Gentler Decimal Floating-Point
- From: glen herrmannsfeldt
- Re: Gentler Decimal Floating-Point
- From: Nick Maclaren
- Re: Gentler Decimal Floating-Point
- From: Mike Cowlishaw
- Re: Gentler Decimal Floating-Point
- From: Quadibloc
- Re: Gentler Decimal Floating-Point
- From: Mike Cowlishaw
- Re: Gentler Decimal Floating-Point
- From: Quadibloc
- Re: Gentler Decimal Floating-Point
- From: Nick Maclaren
- Re: Gentler Decimal Floating-Point
- From: Quadibloc
- Re: Gentler Decimal Floating-Point
- From: glen herrmannsfeldt
- Re: Gentler Decimal Floating-Point
- From: Quadibloc
- Gentler Decimal Floating-Point
- Prev by Date: Re: Gentler Decimal Floating-Point
- Next by Date: Re: Gentler Decimal Floating-Point
- Previous by thread: Re: Gentler Decimal Floating-Point
- Next by thread: Re: Gentler Decimal Floating-Point
- Index(es):
Relevant Pages
|
|