In view of the current thread of floating-point input and output, how
should we specify FCONSTANTs ? My concern is when the system potentially uses single, double, or extended-double (or worse).
Is the algorithm that guarantees that a printed number can be converted 'losslessly' back to its internal presentation able to do that
regardless of the number of bits in the internal representation?
We probably don't want that FP library code developed for a double implementation specifies table constants etc. that are depending on the precision of its internal implementation. (I had this problem last week
when porting a ddfloat library to xdfloats, although there it was
especially tricky.)
On 10/12/26 5:40 AM, marcel hendrix wrote:
In view of the current thread of floating-point input and output, how
should we specify FCONSTANTs ? My concern is when the system
potentially uses single, double, or extended-double (or worse).
... For all IEEE binary
formats, the number of decimal digits which must be specified for
roundtrip binary -> decimal -> binary are given in the IEEE 754
standard. For double precision, it is 17.
..
from the IEEE 754 standard:
Limits on correctly rounded conversion:
binary16: Pmin = 5 digits
binary32: Pmin = 9 digits
binary64: Pmin = 17 digits
binary128: Pmin = 36 digits
For all other binary formats bf,
Pmin(bf) = 1 + ceiling(p*log_10(2)), where p is the number of
significant bits in bf.
e.g. for double precision, p = 53 bit significand, the above formula
gives 17 decimal digits.
For 64 bit significand (80-bit extended precision) , the formula gives
21 digits.
...
[UNDEFINED] FCEIL [IF]
: FCEIL ( F: r1 -- r2 ) FNEGATE FLOOR FNEGATE ;
[THEN]
: P_min ( u1 -- u2) S>F _FLOG2 F* FCEIL F>D DROP 1+ ;
XD (xdfe.) DROP #25 4 + CR TYPE3.1415926535897932384626433835121212121212e
On 10/12/2026 4:14 PM, Krishna Myneni wrote:
[..]> 2.0e0 FLOG FCONSTANT _FLOG2
[UNDEFINED] FCEIL [IF]
: FCEIL ( F: r1 -- r2 ) FNEGATE FLOOR FNEGATE ;
[THEN]
: P_min ( u1 -- u2) S>F _FLOG2 F* FCEIL F>D DROP 1+ ;
FORTH> xd=pi (xdfe.) 2dup CR TYPE-a DROP #25 4 + CR TYPE 3.14159265358979323846264338327950288422e0
3.141592653589793238462643383 ok
So here it is easy to see it is correct.
What if PI had been 3.1415926535897932384626433835121212121212 ?
FORTH> s" 3.1415926535897932384626433835121212121212e" cr 2dup TYPE
XD (xdfe.) DROP #25 4 + CR TYPE3.1415926535897932384626433835121212121212e
3.141592653589793238462643383 ok
Maybe don't ever output more than 25 digits?
On 10/12/26 9:56 AM, marcel hendrix wrote:
On 10/12/2026 4:14 PM, Krishna Myneni wrote:
[..]> 2.0e0 FLOG FCONSTANT _FLOG2
[UNDEFINED] FCEIL [IF]
: FCEIL ( F: r1 -- r2 ) FNEGATE FLOOR FNEGATE ;
[THEN]
What binary precision (number of significand bits) are you using forxdfloats are 128 bits ( 2 extended doubles [80 bits] ).
your xdfloats?
On 10/12/2026 6:08 PM, Krishna Myneni wrote:
On 10/12/26 9:56 AM, marcel hendrix wrote:
On 10/12/2026 4:14 PM, Krishna Myneni wrote:
[..]> 2.0e0 FLOG FCONSTANT _FLOG2
[UNDEFINED] FCEIL [IF]
: FCEIL ( F: r1 -- r2 ) FNEGATE FLOOR FNEGATE ;
[THEN]
[..]
What binary precision (number of significand bits) are you using forxdfloats are 128 bits ( 2 extended doubles [80 bits] ).
your xdfloats?
ddfloats are 106 bits ( 2 doubles [53 bits] ).
The '25' is based on an extended float (64 bit mantissa).
In view of the current thread of floating-point input and output, how
should we specify FCONSTANTs ? My concern is when the system potentially >uses single, double, or extended-double (or worse).
Is the algorithm that guarantees that a printed number can be converted >'losslessly' back to its internal presentation able to do that
regardless of the number of bits in the internal representation?
We probably don't want that FP library code developed for a double >implementation specifies table constants etc. that are depending on the >precision of its internal implementation.
marcel hendrix <mhx@iae.nl> writes:
In view of the current thread of floating-point input and output, how
should we specify FCONSTANTs ? My concern is when the system potentially
uses single, double, or extended-double (or worse).
Standard Forth only has one FP type on the FP stack, and FCONSTANT
stores that and pushes that, just like F! and F@ do.
Is the algorithm that guarantees that a printed number can be converted
'losslessly' back to its internal presentation able to do that
regardless of the number of bits in the internal representation?
Sure.
...you can derive the numbers...We probably don't want that FP library code developed for a double
implementation specifies table constants etc. that are depending on the
precision of its internal implementation.
You will have to work with some limit, but I expect that you can make
numbers with, say 36 digits, and ideally you can derive the numbers
for various formats up to binary128 from that. But if the mathematics
behind these numbers is not just to use an approximation to something,
but to have a bias that corrects for some error elsewhere, maybe that
is not enough.
On 10/12/2026 8:36 PM, Anton Ertl wrote:
marcel hendrix <mhx@iae.nl> writes:
In view of the current thread of floating-point input and output, how
should we specify FCONSTANTs ? My concern is when the system potentially >>> uses single, double, or extended-double (or worse).
Standard Forth only has one FP type on the FP stack, and FCONSTANT
stores that and pushes that, just like F! and F@ do.
Procrustes Forth? On such a system SF@/! and DF@/! must convert an
internal to an external format, and the conversion must be precise.
Switching between single and double precision is a well-known trick to >improve convergence of certain algorithms.
Is the algorithm that guarantees that a printed number can be converted
'losslessly' back to its internal presentation able to do that
regardless of the number of bits in the internal representation?
Sure.
My question is: if we have a text representation of a number with say 40
(or whatever) digits, will that unchanged string work to give the
best approximation on single, double, ... binary internal formats?
Is your answer to that: 'Sure' ?
You will have to work with some limit, but I expect that you can make...you can derive the numbers...
numbers with, say 36 digits, and ideally you can derive the numbers
for various formats up to binary128 from that. But if the mathematics
behind these numbers is not just to use an approximation to something,
but to have a bias that corrects for some error elsewhere, maybe that
is not enough.
The question still is: How?
marcel hendrix <mhx@iae.nl> writes:
In view of the current thread of floating-point input and output, how
should we specify FCONSTANTs ? My concern is when the system potentially >>> uses single, double, or extended-double (or worse).
Standard Forth only has one FP type on the FP stack, and FCONSTANT
stores that and pushes that, just like F! and F@ do.
Procrustes Forth? On such a system SF@/! and DF@/! must convert an
internal to an external format, and the conversion must be precise.
Switching between single and double precision is a well-known trick to >improve convergence of certain algorithms. This conversion *could* be a >serious headache.
The question still is: How?The answer is "mu".
-marcel
The illusion that you can do something precise with imprecise numbers ...
On 10/12/26 11:38 AM, marcel hendrix wrote:
On 10/12/2026 6:08 PM, Krishna Myneni wrote:
On 10/12/26 9:56 AM, marcel hendrix wrote:
On 10/12/2026 4:14 PM, Krishna Myneni wrote:
[..]> 2.0e0 FLOG FCONSTANT _FLOG2
[UNDEFINED] FCEIL [IF]
: FCEIL ( F: r1 -- r2 ) FNEGATE FLOOR FNEGATE ;
[THEN]
[..]
What binary precision (number of significand bits) are you using forxdfloats are 128 bits ( 2 extended doubles [80 bits] ).
your xdfloats?
ddfloats are 106 bits ( 2 doubles [53 bits] ).
The '25' is based on an extended float (64 bit mantissa).
The problem could be at the front end (decimal string to binaryThis is a very good and helpful suggestion. It deepened my
conversion) or for the inverse case (binary to decimal string), or
possibly both. For now, you could test with a single specified extended float binary value and output it to 21 decimal digits and see if it
cycles back to the same binary value. To test the cycling, you have to
start with the binary value. If that fails, it would indicate a problem.
albert@spenarnc.xs4all.nl writes:
The illusion that you can do something precise with imprecise numbers ...
What is an "imprecise number"? In any case, every FP number has a
precise value. It may not be the value you are interested in, but
that does not make the value any less precise. And thinking about FP
numbers as "imprecise" or intervals etc. leads you down the path to
wrong conclusions.
On 14/10/2026 7:25 pm, Anton Ertl wrote:
What is an "imprecise number"? In any case, every FP number has a
precise value. It may not be the value you are interested in, but
that does not make the value any less precise. And thinking about FP
numbers as "imprecise" or intervals etc. leads you down the path to
wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out >intervals then what are they doing? Following the leader?
On 10/12/2026 8:05 PM, Krishna Myneni wrote:
On 10/12/26 11:38 AM, marcel hendrix wrote:
On 10/12/2026 6:08 PM, Krishna Myneni wrote:
On 10/12/26 9:56 AM, marcel hendrix wrote:
On 10/12/2026 4:14 PM, Krishna Myneni wrote:
[..]> 2.0e0 FLOG FCONSTANT _FLOG2
[UNDEFINED] FCEIL [IF]
: FCEIL ( F: r1 -- r2 ) FNEGATE FLOOR FNEGATE ;
[THEN]
[..]
What binary precision (number of significand bits) are you using forxdfloats are 128 bits ( 2 extended doubles [80 bits] ).
your xdfloats?
ddfloats are 106 bits ( 2 doubles [53 bits] ).
The '25' is based on an extended float (64 bit mantissa).
[..]
This is a very good and helpful suggestion. It deepened my
The problem could be at the front end (decimal string to binary
conversion) or for the inverse case (binary to decimal string), or
possibly both. For now, you could test with a single specified
extended float binary value and output it to 21 decimal digits and see
if it cycles back to the same binary value. To test the cycling, you
have to start with the binary value. If that fails, it would indicate
a problem.
understanding, although a full solution is not obvious yet.
Here are the results for the 128 bit package. Testing is done with three
40 digit numbers, xd=E, xd=PI*2 and xd=3*PI/4. I first convert the full number from text (with the mantissa cut to XDPRECISION digits) to
binary. That binary output is converted back to text (estimate) and then estimate is converted to estimate estimate. The binary of estimate
estimate is compared to the binary of input cut.
It can be observed that the numbers eventually cycle if XDPRECISION is sufficiently high, and they approach the full input better and better
(but not exactly). That doesn't matter because the binary values become indistinguishable although the text representations don't. For instance, with xdprecision = 39,
2.718281828459045235360287471352662497757e0-a and 2.718281828459045235360287471352662497770e0-a give the same binary result.
For lower xdprecision (37) the value for xd=2*pi differs by ~ 2e-38
from its cycled result. This is what I expect from a 128 bit mantissa,
-128e F2^X +e. prints 2.9387358770557187700e-0039.
I interpret this as follows:
-a1. Always use #38 SET-XDPRECISION for computations
-a2. Do not worry when the cycled value of a constant *prints*
-a-a-a differently, it's the binary value that counts
-a3. Rounding numbers must be done by rounding the full precision binary
-a-a-a value like `a human`, not by choosing a lower XDPRECISION. This is
-a-a-a counter-intuitive, but look at the the 27 >XD-TEST result below: the
-a-a-a (estimate2 - input) values differ by 1 decimal, depending on
-a-a-a the input value's digit pattern.
FORTH> 39 >XD-TEST
full input-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 2.7182818284590452353602874713526624977572e0
input cut to 39 places =-a-a 2.718281828459045235360287471352662497757e0 estimate-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 2.718281828459045235360287471352662497770e0
estimate of estimate-a-a-a-a-a-a 2.718281828459045235360287471352662497770e0 estimate2 - input =-a 0e0
full input-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 6.2831853071795864769252867665590057683943e0
input cut to 39 places =-a-a 6.283185307179586476925286766559005768394e0 estimate-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 6.283185307179586476925286766559005768349e0
estimate of estimate-a-a-a-a-a-a 6.283185307179586476925286766559005768349e0 estimate2 - input =-a 0e0
full input-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 2.3561944901923449288469825374596271631478e0
input cut to 39 places =-a-a 2.356194490192344928846982537459627163147e0 estimate-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 2.356194490192344928846982537459627163137e0
estimate of estimate-a-a-a-a-a-a 2.356194490192344928846982537459627163137e0 estimate2 - input =-a 0e0
( expect optimal result for XDPRECISION = 38 ) ok
FORTH> 38 >XD-TEST
full input-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 2.7182818284590452353602874713526624977572e0
input cut to 38 places =-a-a 2.71828182845904523536028747135266249775e0 estimate-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 2.71828182845904523536028747135266249777e0
estimate of estimate-a-a-a-a-a-a 2.71828182845904523536028747135266249777e0 estimate2 - input =-a 0e0
full input-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 6.2831853071795864769252867665590057683943e0
input cut to 38 places =-a-a 6.28318530717958647692528676655900576839e0 estimate-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 6.28318530717958647692528676655900576844e0
estimate of estimate-a-a-a-a-a-a 6.28318530717958647692528676655900576844e0 estimate2 - input =-a 0e0
full input-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 2.3561944901923449288469825374596271631478e0
input cut to 38 places =-a-a 2.35619449019234492884698253745962716314e0 estimate-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 2.35619449019234492884698253745962716313e0
estimate of estimate-a-a-a-a-a-a 2.35619449019234492884698253745962716313e0 estimate2 - input =-a 0e0
( expect optimal result for XDPRECISION = 38 ) ok
dxf <dxforth@gmail.com> writes:
On 14/10/2026 7:25 pm, Anton Ertl wrote:
What is an "imprecise number"? In any case, every FP number has a
precise value. It may not be the value you are interested in, but
that does not make the value any less precise. And thinking about FP
numbers as "imprecise" or intervals etc. leads you down the path to
wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out
intervals then what are they doing? Following the leader?
If you give a precise REPRESENT a big-enough buffer, it gives you the
decimal representation of the floating-point value, exactly.
...
It seems pretty obvious to me that REPRESENT (whether high-quality or
not) does not output an interval. An interval is indicated by two
numbers, REPRESENT only outputs one.
On 14/10/2026 7:25 pm, Anton Ertl wrote:
albert@spenarnc.xs4all.nl writes:
The illusion that you can do something precise with imprecise numbers ... >>What is an "imprecise number"? In any case, every FP number has a
precise value. It may not be the value you are interested in, but
that does not make the value any less precise. And thinking about FP
numbers as "imprecise" or intervals etc. leads you down the path to
wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out intervals then what are they doing? Following the leader?
On 15/10/2026 4:55 pm, Anton Ertl wrote:
dxf <dxforth@gmail.com> writes:
On 14/10/2026 7:25 pm, Anton Ertl wrote:
What is an "imprecise number"? In any case, every FP number has a
precise value. It may not be the value you are interested in, but
that does not make the value any less precise. And thinking about FP
numbers as "imprecise" or intervals etc. leads you down the path to
wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out
intervals then what are they doing? Following the leader?
If you give a precise REPRESENT a big-enough buffer, it gives you the
decimal representation of the floating-point value, exactly.
It gives a decimal representation of the nearest storage slot that the >floating-point value was assigned.
That floating-point value never had
more than 17 useful digits.
The question then becomes why? Why deliberately misrepresent users?
I'd have to fall on my head.
It seems pretty obvious to me that REPRESENT (whether high-quality or
not) does not output an interval. An interval is indicated by two
numbers, REPRESENT only outputs one.
Print two and the interval becomes obvious.
II. Possible meanings of "high quality" REPRESENT
extended precision (p = 64 bits)
double double precision (p = 106 bits)
quad precision (p = 113 bits)
double extended precision (p = 128 bits)
double quad precision (p = 226 bits)
dxf <dxforth@gmail.com> writes:
On 14/10/2026 7:25 pm, Anton Ertl wrote:
What is an "imprecise number"? In any case, every FP number has a
precise value. It may not be the value you are interested in, but
that does not make the value any less precise. And thinking about FP
numbers as "imprecise" or intervals etc. leads you down the path to
wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out >>intervals then what are they doing? Following the leader?
If you give a precise REPRESENT a big-enough buffer, it gives you the
decimal representation of the floating-point value, exactly.
If you give it a buffer that's too short for the exact representation,
you get a rounded result, rounded to the nearest decimal number that
fits in the buffer.
It seems pretty obvious to me that REPRESENT (whether high-quality or
not) does not output an interval. An interval is indicated by two
numbers, REPRESENT only outputs one.
- anton--
Krishna Myneni <krishna.myneni@ccreweb.org> writes:
II. Possible meanings of "high quality" REPRESENT
Another meaning is that it produces as many digits as asked for (and
to use the correct rounding in cases where the asked-for digits are insufficient to represent the number exactly).
This is what Gforth's REPRESENT provides when it is based on ecvt_r()
in glibc 2.36 (and probably newer, and probably some older glibcs).
extended precision (p = 64 bits)
double double precision (p = 106 bits)
quad precision (p = 113 bits)
double extended precision (p = 128 bits)
double quad precision (p = 226 bits)
Then M = 70, and H >= 73 significant digits.
A fp number represents a rational range, it nominal value plus or minus
half an ulp.
On 10/16/2026 5:58 AM, Krishna Myneni wrote:
extended precision (p = 64 bits)
double double precision (p = 106 bits)
quad precision (p = 113 bits)
double extended precision (p = 128 bits)
double quad precision (p = 226 bits)
Then M = 70, and H >= 73 significant digits.
Which implies H >= 83 for quad double extended precision,
meaning the available QD* in that library is not sufficient.
Although only QDNEGATE , qd=10 QD* , qd=10 QD/ , and QDF+ are needed,
one can't get by with a bit shift routine and a simple QQDF+, as +/-INF,
NAN and subnormals must be handled.
Or give up in disgust and link to an external library.
Either that or go for II.2.
-marcel
On 10/16/26 10:36, marcel hendrix wrote:
On 10/16/2026 5:58 AM, Krishna Myneni wrote:
extended precision (p = 64 bits)
double double precision (p = 106 bits)
quad precision (p = 113 bits)
double extended precision (p = 128 bits)
double quad precision (p = 226 bits)
Then M = 70, and H >= 73 significant digits.
Which implies H >= 83 for quad double extended precision,
meaning the available QD* in that library is not sufficient.
Although only QDNEGATE , qd=10 QD* , qd=10 QD/ , and QDF+ are needed,
one can't get by with a bit shift routine and a simple QQDF+, as +/-
INF, NAN and subnormals must be handled.
Or give up in disgust and link to an external library.
Either that or go for II.2.
-marcel
Yes, I expect QD* which I assume is quad double mulitply is probably not sufficient to handle quad extended requirements. One point I forgot to mention is that the Forth standard for REPRESENT requires rounding to nearest, in which case H_min = M (not M+3). There's no way I can see to avoid using big number arithmetic for the quad extended precision case.
It's not hopeless. We have big number arithmetic library code in Forth
with which to learn how to deal with just about any case. The learning
curve is there, of course.
To handle +/-INF and NAN, isn't it sufficient to examine the bit patternI hope that is true, I don't particularly enjoy looking into the MPFR again.
for the leading extended precision number in the quad extended precision
set i.e. no arithmetic should be needed to handle +/-INF and NAN? I'm
not sure if subnormals will be more difficult to handle than normal
numbers -- their precision is always less than or equal to normal numbers.
On 10/16/2026 6:02 PM, Krishna Myneni wrote:
On 10/16/26 10:36, marcel hendrix wrote:
On 10/16/2026 5:58 AM, Krishna Myneni wrote:
extended precision (p = 64 bits)
double double precision (p = 106 bits)
quad precision (p = 113 bits)
double extended precision (p = 128 bits)
double quad precision (p = 226 bits)
Then M = 70, and H >= 73 significant digits.
Which implies H >= 83 for quad double extended precision,
meaning the available QD* in that library is not sufficient.
Although only QDNEGATE , qd=10 QD* , qd=10 QD/ , and QDF+ are needed,
one can't get by with a bit shift routine and a simple QQDF+, as +/-
INF, NAN and subnormals must be handled.
Or give up in disgust and link to an external library.
Either that or go for II.2.
-marcel
Yes, I expect QD* which I assume is quad double mulitply is probably
not sufficient to handle quad extended requirements. One point I
forgot to mention is that the Forth standard for REPRESENT requires
rounding to nearest, in which case H_min = M (not M+3). There's no way
I can see to avoid using big number arithmetic for the quad extended
precision case.
An iForth QD library will have a quad double extended multiply QD* for
256 bits. Then -256e F2^x gives 8.6e-78 ~> 77 usable decimals.
Your `2e FLOG 256e F* FCEIL F1+` formula (even rounding) gives M = 79,
and unfortunately, QD* does not suffice.
It's not hopeless. We have big number arithmetic library code in Forth
with which to learn how to deal with just about any case. The learning
curve is there, of course.
I don't know there is a Forth-based arbitrary *float* implementation,
but the MPFR was ported back in 2012. I am looking at it just now. The Windows port suffered from a very immature MinGW64 and would need to be revisited.
But why want QD, QX or QD when the mpfr gives arbitrary precision on its own? The charm of QD is that is very small and simple, while MPFR is a beast. It could be that it is much faster than QD/QX and QD though.
Maybe some tests could be done first.
To handle +/-INF and NAN, isn't it sufficient to examine the bitI hope that is true, I don't particularly enjoy looking into the MPFR
pattern for the leading extended precision number in the quad extended
precision set i.e. no arithmetic should be needed to handle +/-INF and
NAN? I'm not sure if subnormals will be more difficult to handle than
normal numbers -- their precision is always less than or equal to
normal numbers.
again.
dxf <dxforth@gmail.com> writes:
On 15/10/2026 4:55 pm, Anton Ertl wrote:
dxf <dxforth@gmail.com> writes:
On 14/10/2026 7:25 pm, Anton Ertl wrote:
What is an "imprecise number"? In any case, every FP number has a
precise value. It may not be the value you are interested in, but
that does not make the value any less precise. And thinking about FP >>>>> numbers as "imprecise" or intervals etc. leads you down the path to
wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out
intervals then what are they doing? Following the leader?
If you give a precise REPRESENT a big-enough buffer, it gives you the
decimal representation of the floating-point value, exactly.
It gives a decimal representation of the nearest storage slot that the
floating-point value was assigned.
Storage slot? Are your postings AI slop?
Anyway, every binary FP number can be represented exactly as decimal
number, but some FP numbers need a large number of digits in decimal representation. Gforth's E.EXACT outputs this decimal representation,
when based on an appropriate ecvt_r() (such as that in glibc 2.36).
That floating-point value never had
more than 17 useful digits.
How many digits are useful depends on the use. In particular, if you
want to know the exact decimal representation of an FP value, often
more than 17 digits are necessary, and therefore, for this use,
useful.
The question then becomes why? Why deliberately misrepresent users?
I'd have to fall on my head.
More AI slop?
...
On 16/10/2026 4:12 pm, Anton Ertl wrote:
dxf <dxforth@gmail.com> writes:
On 15/10/2026 4:55 pm, Anton Ertl wrote:
dxf <dxforth@gmail.com> writes:
On 14/10/2026 7:25 pm, Anton Ertl wrote:
What is an "imprecise number"? In any case, every FP number has a >>>>>> precise value. It may not be the value you are interested in, but >>>>>> that does not make the value any less precise. And thinking about FP >>>>>> numbers as "imprecise" or intervals etc. leads you down the path to >>>>>> wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out >>>>> intervals then what are they doing? Following the leader?
If you give a precise REPRESENT a big-enough buffer, it gives you the
decimal representation of the floating-point value, exactly.
It gives a decimal representation of the nearest storage slot that the
floating-point value was assigned.
Storage slot? Are your postings AI slop?
Did you have a problem understanding it? I've never used AI.
Anyway, every binary FP number can be represented exactly as decimal
number, but some FP numbers need a large number of digits in decimal
representation. Gforth's E.EXACT outputs this decimal representation,
when based on an appropriate ecvt_r() (such as that in glibc 2.36).
That floating-point value never had
more than 17 useful digits.
How many digits are useful depends on the use. In particular, if you
want to know the exact decimal representation of an FP value, often
more than 17 digits are necessary, and therefore, for this use,
useful.
There's 'uses' but you can't give any.
On 10/14/26 8:40 PM, dxf wrote:
On 14/10/2026 7:25 pm, Anton Ertl wrote:
albert@spenarnc.xs4all.nl writes:
The illusion that you can do something precise with imprecise numbers ... >>>What is an "imprecise number"?-a In any case, every FP number has a
precise value.-a It may not be the value you are interested in, but
that does not make the value any less precise.-a And thinking about FP
numbers as "imprecise" or intervals etc. leads you down the path to
wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out
intervals then what are they doing?-a Following the leader?
Let's attempt to give a more precise meaning to what is meant by a "high quality" REPRESENT using the IEEE 754 standard as a guide. There are several possibilities. First, some definitions from the IEEE 754 standard, and then some possible meanings when we say "high quality".
I. Definitions:
P_min = minimum of number of decimal digits needed, with round to nearest, for conversion from internal normalized binary representation to decimal output for the significand, which, when converted back to binary form gives the same binary significand:
P_min( p ) = 1 + ceiling(p*log_10(2)); p is the number of significant bits (both actual and implied) of the significand in the binary format.
If a Forth system supports multiple binary formats, define
M = max{P_min(p_i)} where i indexes the binary format
Example: For a Forth system supports both single-precision and double-precision IEEE binary formats,
M = max{ P_min(24), P_min(53) } = max{ 9, 17 } = 17
II. Possible meanings of "high quality" REPRESENT
There are 3 sensible choices, in my opinion:
II.1) On a given Forth system, REPRESENT will output, with rounding to nearest a minimum of digits, M, given by maximum of P_min for all supported binary formats.
For example, if a Forth system supports nothing above binary double precision (binary64), it should be capable of providing M = 17 significant decimal digits, with round to nearest.
II.2) Follow the IEEE 754 standard and specify that the Forth system has "an implementation-defined limit on the number of significant digits that can be converted with correct rounding to and from supported binary formats. That limit, H, shall be such that H reN M + 3 and it should be that H is unbounded."
Then, the minimum number of significant digits for a system which supports nothing higher than binary64, it should provide at least H = 20 significant digits in any specified rounding mode.
Note that the IEEE 754 standard goes to pains to specify there is no upper bound on H, only a lower bound.
II.3) Provide H significant decimal digits to support most *fixed length* binary formats currently in use, whether they are internally supported by the Forth system or supported via source code. Some fixed length binary formats currently in use are:
extended precision (p = 64 bits)
double double precision (p = 106 bits)
quad precision (p = 113 bits)
double extended precision (p = 128 bits)
double quad precision (p = 226 bits)
Then M = 70, and H >= 73 significant digits.
Of the three choices above, II.1 or II.2 is probably what smaller systems would choose: M = 17 or H = H_min = 20 significant digits. If they want to provide double double precision, then II.2 would be a better choice (H = H_min = 36 significant digits).
Systems with less memory constraints should choose II.3.
On 10/16/26 9:37 PM, dxf wrote:
On 16/10/2026 4:12 pm, Anton Ertl wrote:
dxf <dxforth@gmail.com> writes:
On 15/10/2026 4:55 pm, Anton Ertl wrote:
dxf <dxforth@gmail.com> writes:
On 14/10/2026 7:25 pm, Anton Ertl wrote:
What is an "imprecise number"?-a In any case, every FP number has a >>>>>>> precise value.-a It may not be the value you are interested in, but >>>>>>> that does not make the value any less precise.-a And thinking about FP >>>>>>> numbers as "imprecise" or intervals etc. leads you down the path to >>>>>>> wrong conclusions.
If the recently-dubbed "high quality" REPRESENTs aren't printing out >>>>>> intervals then what are they doing?-a Following the leader?
If you give a precise REPRESENT a big-enough buffer, it gives you the >>>>> decimal representation of the floating-point value, exactly.
It gives a decimal representation of the nearest storage slot that the >>>> floating-point value was assigned.
Storage slot?-a Are your postings AI slop?
Did you have a problem understanding it?-a I've never used AI.
-a
Anyway, every binary FP number can be represented exactly as decimal
number, but some FP numbers need a large number of digits in decimal
representation.-a Gforth's E.EXACT outputs this decimal representation,
when based on an appropriate ecvt_r() (such as that in glibc 2.36).
That floating-point value never had
more than 17 useful digits.
How many digits are useful depends on the use.-a In particular, if you
want to know the exact decimal representation of an FP value, often
more than 17 digits are necessary, and therefore, for this use,
useful.
There's 'uses' but you can't give any.
Yes, you are clearly smarter than the entire IEEE 754 standards committee,
which specified that a system should leave the number of digits requested in a binary to decimal conversion to be unbounded.
One use case clearly shows up in this thread with Marcel's implementation of xdfloats.
albert@spenarnc.xs4all.nl writes:
A fp number represents a rational range, it nominal value plus or minus >>half an ulp.
What makes you think that the result of
3 s>f
or
s" 3e" >float drop
represents a range? This value can be represented exactly as FP
value, there is no rounding happening in this conversion.
And why should it represent the range
2.9999999999999997779553950749686919152736663818359375e to >3.0000000000000002220446049250313080847263336181640625e
in particular?
Further, when we perform
6 s>f 3 s>f f-
why should the results of the individual conversions (none of which
performs rounding) represent ranges? Why should the result of the >subtraction (which does not perform any rounding, either, and does not
set the "inexact" flag in the FPU) represent a range.
But even if we assume that the results of the conversions are ranges,
why should the result of the subtraction be the interval above,
instead of the interval that interval arithmetic would give, which is
a range that is 3 times bigger in this case (2 times, because the
interval you claim for 6 is twice as big as that for 3, and 1 time due
to the interval of 3).
As mentioned, thinking about FP numbers as "imprecise" or intervals
etc. leads you down the path to wrong conclusions.
A better way to think about them is: Each FP number has an exact
value, but in some cases conversions to FP and FP operations round,
because there is no FP value for the exact result; this rounding leads
to errors. The size of this error is the subject of numerical
analysis.
- anton--
On 17/10/2026 3:37 pm, Krishna Myneni wrote:...
One use case clearly shows up in this thread with Marcel's implementation of xdfloats.
Can't make head or tail of that.
In article <2026Oct16.174024@mips.complang.tuwien.ac.at>,I think you meant (done with xopg, mpfr, mpc):
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
albert@spenarnc.xs4all.nl writes:
Exactly
0.0001E0 DUP FSIN F-
looses a whole lot of precision.
Maybe "imprecise numbers" is not a bad name after all.
I aim for psychological impact.
In article <2026Oct16.174024@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
albert@spenarnc.xs4all.nl writes:
ExactlyI think you meant (done with xopg, mpfr, mpc):
0.0001E0 DUP FSIN F-
looses a whole lot of precision.
Maybe "imprecise numbers" is not a bad name after all.
I aim for psychological impact.
FORTH> LET sin(0.0001e):
.print 9.9999999833333333416666666646825396828152e-0005 ok
FORTH> S" 0.0001e" >XD XDSIN
XDFE. 9.99999998333333334166666666468253968286e-5 ok
FORTH> 0.0001e FSIN
+e. 9.9999999833333333426e-0005 ok
FORTH> LET sin(0.1001e):
.print 9.9932916564023038037792141684528699818587e-0002 ok
FORTH> S" 0.1001e" >XD XDSIN
XDFE. 9.99329165640230380377921416845286998177e-2 ok
FORTH> 0.1001e FSIN
+e. 9.9932916564023038040e-0002 ok
... although this is most probably due to improper range reduction.
The target (non-AI) audience knows what they are doing, so why not
give them the best possible tools?
-marcel--
But why want QD, QX or QD when the mpfr gives arbitrary precision on its own? The charm of QD is that is very small and simple, while MPFR is a beast. It could be that it is much faster than QD/QX and QD though.As MPFR and MPC again work in iForth (inside XOPG), I did the testing.
Maybe some tests could be done first.
In article <2026Oct16.174024@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
A better way to think about them is: Each FP number has an exact
value, but in some cases conversions to FP and FP operations round,
because there is no FP value for the exact result; this rounding leads
to errors. The size of this error is the subject of numerical
analysis.
Exactly
0.0001E0 DUP FSIN F-
looses a whole lot of precision.
Maybe "imprecise numbers" is not a bad name after all.
When Intel developed the 8087 it was with IEEE double-precision in mind. >There's little doubt its the reason they chose an internal representation
of 80 bits to handle at least some of IEEE's arithmetic and conversion >requirements.
Yes, you are clearly smarter than the entire IEEE 754 standards
committee, which specified that a system should leave the number of
digits requested in a binary to decimal conversion to be unbounded.
albert@spenarnc.xs4all.nl writes:Good catch.
In article <2026Oct16.174024@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
A better way to think about them is: Each FP number has an exact
value, but in some cases conversions to FP and FP operations round, >>>because there is no FP value for the exact result; this rounding leads
to errors. The size of this error is the subject of numerical
analysis.
Exactly
0.0001E0 DUP FSIN F-
I assume you mean FDUP here.
looses a whole lot of precision.
Maybe "imprecise numbers" is not a bad name after all.
It is. It's not the numbers that are imprecise, it's the operations.
They round (but not in every case).
In the present case the conversion from the decimal string to the FP
number rounds (but that makes little difference for what follows), and
FSIN rounds. F- does not round in this case, but the absolute error
from the FSIN rounding is still present in the result and is
relatively larger compared to the result, so the number of significant
digits is smaller; this phenomenon is called cancellation.
- anton
On 10/17/26 4:11 AM, dxf wrote:
On 17/10/2026 3:37 pm, Krishna Myneni wrote:...
One use case clearly shows up in this thread with Marcel's implementation of xdfloats.
Can't make head or tail of that.
Taking the position that anything you don't understand at first glance, without effort, works for you, ok.
But it may not be an indication that there is a conspiracy of mathematicians and computer scientists.
On 17-10-2026 06:37, Krishna Myneni wrote:
Yes, you are clearly smarter than the entire IEEE 754 standards
committee, which specified that a system should leave the number of
digits requested in a binary to decimal conversion to be unbounded.
Err. Not quite. IEEE 754-2008 permits an implementation-defined limit H, provided it meets the standard's minimum requirements. It recommends
that H be unbounded, but doesn't make an unbounded limit mandatory for binary-format conversions.
Small correction ;-) It's the difference between "shall" and "should".
In technical specifications, ISO standards, and quality management
systems, shall and should have distinct, legally binding meanings:
Maybe "imprecise numbers" is not a bad name after all.
I aim for psychological impact.
Which implies H >= 83 for quad double extended precision,
marcel hendrix <mhx@iae.nl> writes:
Which implies H >= 83 for quad double extended precision,
Extended precision = 80 bit numbers? So double extended = 160 bits, and
quad double extended = 640 bits? Do you mean double quad extended which would be 320 bits?
I think for all of these, anything above 256 bits
and maybe anything above 128 bits, you probably want some MPFR-like
arbitrary precision.
80 bit extended is looking like an x86 artifact by now, maybe. I wonder
if anything implements 128 bit extended. There's a spec for it in
RISC-V but no implementations that I know of.
...
80 bit extended is looking like an x86 artifact by now, maybe.
No, extended double is an IEEE format that, e.g., matches the IntelWhich implies H >= 83 for quad double extended precision, ...
FPU's 10 byte memory storage and has a mantissa of 64 bits.
a quad extended double will have a 256 bit mantissa.
MPFR is definitely much faster.
The xd-fp library, with a full set of math functions, is only 800
lines of Forth including comments.
Nice, what is the memory representation?
The xd-fp library, with a full set of math functions, is only 800
lines of Forth including comments.
That's pretty good, I thought carefully done math functions could be
messy.
On 10/18/26 7:10 AM, Hans Bezemer wrote:
On 17-10-2026 06:37, Krishna Myneni wrote:
Yes, you are clearly smarter than the entire IEEE 754 standards
committee, which specified that a system should leave the number of
digits requested in a binary to decimal conversion to be unbounded.
Err. Not quite. IEEE 754-2008 permits an implementation-defined limit
H, provided it meets the standard's minimum requirements. It
recommends that H be unbounded, but doesn't make an unbounded limit
mandatory for binary-format conversions.
Small correction ;-) It's the difference between "shall" and "should".
In technical specifications, ISO standards, and quality management
systems, shall and should have distinct, legally binding meanings:
Yes, I know what "should" means. There is no claim for legal binding,
and my suggested meanings for "high quality REPRESENT" allow for H to be
set to a fixed value.
On 18-10-2026 17:08, Krishna Myneni wrote:
On 10/18/26 7:10 AM, Hans Bezemer wrote:
On 17-10-2026 06:37, Krishna Myneni wrote:
Yes, you are clearly smarter than the entire IEEE 754 standards
committee, which specified that a system should leave the number of
digits requested in a binary to decimal conversion to be unbounded.
Err. Not quite. IEEE 754-2008 permits an implementation-defined limit
H, provided it meets the standard's minimum requirements. It
recommends that H be unbounded, but doesn't make an unbounded limit
mandatory for binary-format conversions.
Small correction ;-) It's the difference between "shall" and
"should". In technical specifications, ISO standards, and quality
management systems, shall and should have distinct, legally binding
meanings:
Yes, I know what "should" means. There is no claim for legal binding,
and my suggested meanings for "high quality REPRESENT" allow for H to
be set to a fixed value.
"which specified that a system should leave the number of digits
requested in a binary to decimal conversion to be unbounded." Actually
-- it didn't, as I've proven beyond a reasonable doubt. That means you
were wrong -- and making more than one claim that wasn't supported on
any standard.
I advise you to do your home work properly before publicly stating that
a commenter is stupid and ignorant. If you wanna play lazy, be my guest.
...
On 10/25/26 9:05 AM, Hans Bezemer wrote:
On 18-10-2026 17:08, Krishna Myneni wrote:
On 10/18/26 7:10 AM, Hans Bezemer wrote:
On 17-10-2026 06:37, Krishna Myneni wrote:
Yes, you are clearly smarter than the entire IEEE 754 standards
committee, ...
As far as that comment is concerned, yes, it was a bit of sarcasm, in response to claims by a poster that everyone else except him wasI don't think that "insulting" fits my definition of "sarcasm".
operating in some thought bubble concerning binary to decimal floating
point conversion.
I don't believe I am smarter than the IEEE 754 committee, which is why I made the effort to read the standard and try to understand what it says.Strange. I've always considered the strength of an argument -- instead
For those concerned, I'm not interesting in getting into fights withOh. So I supposed you blocked yourself -- by calling others stupid and ignorant. Because -- that sounds like a clear invitation for a prolonged verbal disagreement. And I haven't seen an apology yet..
people on the internet, and I will block idiots who are looking for a
fight.
That limit, H, shall be such that H reN M + > 3 and *it should be that H is unbounded.*"
But -- if this should be a covert threat towards me -- see how much I
care :-) But remember, I can post all kinds of stuff to your posts, and you'll never know why people are laughing at you!
On 10/26/26 3:05 PM, Krishna Myneni wrote:
On 10/25/26 9:05 AM, Hans Bezemer wrote:
On 18-10-2026 17:08, Krishna Myneni wrote:
On 10/18/26 7:10 AM, Hans Bezemer wrote:
On 17-10-2026 06:37, Krishna Myneni wrote:
Yes, you are clearly smarter than the entire IEEE 754 standards
committee, ...
As far as that comment is concerned, yes, it was a bit of sarcasm, in response to claims by a poster that everyone else except him was operating in some thought bubble concerning binary to decimal floating point conversion.
I don't believe I am smarter than the IEEE 754 committee, which is why I made the effort to read the standard and try to understand what it says.
...
I don't believe I am smarter than the IEEE 754 committee, which is why I made the effort to read the standard and try to understand what it says.
...
The standard says different things depending upon which version one reads.
Back to IEEE-754. There seems quite a difference between the 1985 and 2008 versions. AFAICT the former gives no meaning to mantissa digits greater than 17 in the case of double precision. It's a problem for those who relied on 'smart' people to think for them because now they're presented with different standards, different committees, different thinking.
On 10/27/2026 11:02 AM, Hans Bezemer wrote:
[..]
But -- if this should be a covert threat towards me -- see how much IYou're way out of line.
care :-) But remember, I can post all kinds of stuff to your posts,
and you'll never know why people are laughing at you!
On 10/27/26 10:40 PM, dxf wrote:
...
...
I don't believe I am smarter than the IEEE 754 committee, which is why I made the effort to read the standard and try to understand what it says.
...
The standard says different things depending upon which version one reads. >>
Back to IEEE-754.-a There seems quite a difference between the 1985 and 2008 >> versions.-a AFAICT the former gives no meaning to mantissa digits greater than
17 in the case of double precision.-a It's a problem for those who relied on >> 'smart' people to think for them because now they're presented with different
standards, different committees, different thinking.
You are still compliant with the standard if you support 17 digit input and output *and* use only round to nearest, despite the updated recommendation that the number of decimal digits be unbounded. There is backwards compatibility in the standard.
On 28/10/2026 10:45 pm, Krishna Myneni wrote:
On 10/27/26 10:40 PM, dxf wrote:
...
...
I don't believe I am smarter than the IEEE 754 committee, which is why I made the effort to read the standard and try to understand what it says.
...
The standard says different things depending upon which version one reads. >>>
Back to IEEE-754.-a There seems quite a difference between the 1985 and 2008
versions.-a AFAICT the former gives no meaning to mantissa digits greater than
17 in the case of double precision.-a It's a problem for those who relied on
'smart' people to think for them because now they're presented with different
standards, different committees, different thinking.
You are still compliant with the standard if you support 17 digit input and output *and* use only round to nearest, despite the updated recommendation that the number of decimal digits be unbounded. There is backwards compatibility in the standard.
Compliance is the last thing. Rationale comes first. I believe the rationale
behind the 1985 requirement (even if not expressly stated) was extracting the last
bit of usable data, cost not considered. Has IEEE-754 2008 posted a rationale for
their extension? Because nothing I've seen posted here suggests a benefit - quite
the opposite.
Whatever GCC is printing - it's not what
the user entered.
As previously mentioned it makes no sense that one can output more significant digits
than one can input - in anyone's universe.
Whatever GCC is printing - it's not what
the user entered.
However, shouldn't we then also do something about
1000000000000000000 7 / . 142857142857142857 vs
1000000000000000000000 7 / . 553688574240601819 ?
1000000000000000000000 7 / .
Or this one on, e.g., VFX Forth 64 :-)
1000000000000 7 / . 555555555555 ok
marcel hendrix <mhx@iae.nl> writes:
Or this one on, e.g., VFX Forth 64 :-)
1000000000000 7 / . 555555555555 ok
Hmm?
[~:173093] vfx64
VFX Forth 64 5.43 [build 0199] 2023-11-09 for Linux x64
-- MicroProcessor Engineering Ltd, 1998-2023
1000000000000 7 / . 142857142857 ok
- anton
dxf <dxforth@gmail.com> writes:
Whatever GCC is printing - it's not what
the user entered.
GCC prints the things you ask it to, usually not FP numbers, but,
e.g., compiler warnings and error messages.
But as for printing what the user entered, here's what Gforth does:
.1000000000000000055511151231257827021181583404541015625e e.exact
outputs
.1000000000000000055511151231257827021181583404541015625e
Admittedly, there are a lot of numbers around that cannot be
represented exactly as binary64 number, and for those the cycle decimal->binary64->decimal (using >FLOAT and E.EXACT based on a recent
glibc release) does not print what is input, but the rounding happens
at decimal->binary64 stage, not on the output.
Does it look any better for, e.g., E. or 17 e.p? Consider
.90000000000000007e
E. prints
.9e
17 E.P prints
.90000000000000002e
Note that none of these numbers has more than 17 decimal digits.
It's not clear to me that IEEE even talks in terms of 'representable' numbers >which leads to the junk that GCC et al print out:
5.1 Overview
"Each of the computational operations that return a numeric result specified by
this standard shall be performed as if it first produced an intermediate result
correct to infinite precision and with unbounded range, and then rounded that
intermediate result, if necessary, to fit in the destinationrCOs format"
On 10/29/2026 10:01 AM, dxf wrote:
As previously mentioned it makes no sense that one can output more significant digits
than one can input - in anyone's universe.
No doubt about that.
Whatever GCC is printing - it's not what
the user entered.
I do that sometimes when I don't know what the hardware/software details of the machine/language are, but do know what I want it to approximate as best as possible, if not exactly.
That does not mean that I wouldn't be surprised if .90000000000000007e e. comes back as 9.0000000000000007000e-1 but .90000000000000000076e e. shows 9.0000000000000000098e-1. ( Unless I now the hardware and software details of the machine. )
However, shouldn't we then also do something about
1000000000000000000 7 / . 142857142857142857-a vs
1000000000000000000000 7 / . 553688574240601819 ?
dxf <dxforth@gmail.com> writes:
It's not clear to me that IEEE even talks in terms of 'representable' numbers
which leads to the junk that GCC et al print out:
5.1 Overview
"Each of the computational operations that return a numeric result specified by
this standard shall be performed as if it first produced an intermediate result
correct to infinite precision and with unbounded range, and then rounded that
intermediate result, if necessary, to fit in the destinationrCOs format"
This already says it: "if necessary". When the result is
representable in the destination's format, rounding is not necessary.
When the destination format is a string buffer with enough digits,
rounding is not necessary, and the exact value can be shown.
OTOH, almost all (as in "all but finitely many") numbers do not fit in binary64, so for almost all numbers that you might convert from a
decimal string to a binary64 FP number, rounding happens on the
conversion. The exceptions are notable, though, e.g., all integers
<=2^53.
- anton
On 30/10/2026 5:47 pm, Anton Ertl wrote:...
dxf <dxforth@gmail.com> writes:
It's not clear to me that IEEE even talks in terms of 'representable' numbersThis already says it: "if necessary". When the result is
which leads to the junk that GCC et al print out:
5.1 Overview
"Each of the computational operations that return a numeric result specified by
this standard shall be performed as if it first produced an intermediate result
correct to infinite precision and with unbounded range, and then rounded that
intermediate result, if necessary, to fit in the destinationrCOs format" >>
representable in the destination's format, rounding is not necessary.
When the destination format is a string buffer with enough digits,
rounding is not necessary, and the exact value can be shown.
The example I gave - 2/3 to infinity
'correctly rounded' - starts failing at the 17th digit when stored in binary64.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 54:24:05 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,563 |