Recent

Author Topic: floating point literals  (Read 4533 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5938
  • Compiler Developer
Re: floating point literals
« Reply #30 on: February 25, 2024, 04:55:13 pm »
So the question as of which directives are supported by push/pop seem to be a legitimate one. The basic rule is, as I always assumed, for every local directive as documented:
Quote
The $PUSH directive saves the current values of all local compiler directives on the settings stack

The development version of the documentation is already improved in that regard (especially note the difference between “directives” and “switches” in the first sentence).

TRon

  • Hero Member
  • *****
  • Posts: 4310
Re: floating point literals
« Reply #31 on: February 25, 2024, 09:03:27 pm »
The development version of the documentation is already improved in that regard (especially note the difference between “directives” and “switches” in the first sentence).
Thank you for that link/hint PascalDragon. tbh I did not check the daily docs regarding this subject  :-X
Today is tomorrow's yesterday.

Paolo

  • Hero Member
  • *****
  • Posts: 581
Re: floating point literals
« Reply #32 on: February 26, 2024, 10:40:48 am »
@fcu thanks to check

@nanobit, thanks for the info, my setting are the nominal one ($excessprecision off), what about this code ? (see the exponent index, all can be rounded in single precision, am I wrong ?)

Code: Pascal  [Select][+][-]
  1. var
  2.   x, y : double;
  3. ...
  4.   x:=0.1;
  5.   y:=y:=1.0E+0009/1.0E+0010;
  6.   if x=y then beep  //<-- never beep
  7.  
  8.   x:=0.1;
  9.   y:=1.0E+0010/1.0E+0011;
  10.   if x=y then beep  //<--- beep
  11.  

thank you
« Last Edit: February 26, 2024, 10:59:47 am by Paolo »

nanobit

  • Full Member
  • ***
  • Posts: 173
Re: floating point literals
« Reply #33 on: February 26, 2024, 12:09:02 pm »
1.0E+0010 (single) and 1.0E+0011 (double, required min type),
so the operation is done in higher precision.

Paolo

  • Hero Member
  • *****
  • Posts: 581
Re: floating point literals
« Reply #34 on: February 26, 2024, 12:17:35 pm »
but the question is exactly this:

why 1.0E+0010 it is assumed as single and 1.0E+0011 double ? 1.0E+0011 still fits in single.
missed something ?

[EDIT] OK I see that 1e+11 is not "correctly" represented in single.
« Last Edit: February 26, 2024, 12:25:54 pm by Paolo »

 

TinyPortal © 2005-2018