Liste des Groupes | Revenir à cl forth |
On 07-04-2025 13:05, dxf wrote:
As a matter of fact, the whole issue can be solved by one single very simple addition to the standard. All my FP systems hold this very definition for SET-PRECISION:
\ 34: Reimplemented PRECISION and SET-PRECISION.
maxdigits VALUE PRECISION
: SET-PRECISION ( n -- ) maxdigits MIN TO PRECISION ;
Since the FLOAT wordset is always in decimal (12.4.1.2 Ambiguous conditions - BASE is not decimal (12.6.1.2143 REPRESENT, 12.6.2.1427 F., 12.6.2.1513 FE., 12.6.2.1613 FS.) it is trivial to calculate the number of significant digits.
The definition given here ( --- CONSTANT MAXDIGITS) ensures that the value issued to SET-PRECISION is always sane.
Of course, if one does not have access to some carnal knowledge concerning the mantissa, one does have a problem concerning porting and maintenance.
6 set-precision ok
1e-4 f. 0.000100000 ok
>
6 set-precision ok
1e-4 f. 0.0001 ok
Les messages affichés proviennent d'usenet.