Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible errors in some constants? #278

Open
DeliciousHair opened this issue Mar 15, 2023 · 2 comments
Open

Possible errors in some constants? #278

DeliciousHair opened this issue Mar 15, 2023 · 2 comments

Comments

@DeliciousHair
Copy link

DeliciousHair commented Mar 15, 2023

Sorry, keyboard flaked out there, hence the open-and-close...

Anyhow, was looking at some math functions like sqrtf() and noticed some oddness / inconsistencies that I thought was worth asking about at the very least. In particular, in sqrtf for example, there is:

const TINY: f32 = 1.0e-30;

while in pow there is:

const TWO53: f64 = 9007199254740992.0; /* 0x43400000_00000000 */
const HUGE: f64 = 1.0e300;
const TINY: f64 = 1.0e-300;

None of these are consistent with the FORTRAN values I assume the concepts are based on. For example:

      PROGRAM SOME_F64_CONSTANTS

      DOUBLE PRECISION   ONE, ZERO
      PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
      DOUBLE PRECISION   EPS, SFMIN, SMALL, BIG

      INTRINSIC          EPSILON, HUGE, TINY

      EPS = EPSILON(ZERO)
      SFMIN = TINY(ZERO)
      SMALL = ONE / HUGE(ZERO)
      BIG = HUGE(ONE)

      PRINT *, "  EPS =", EPS
      PRINT *, "SFMIN =", SFMIN
      PRINT *, "SMALL =", SMALL
      PRINT *, "  BIG =", BIG

      END PROGRAM SOME_f64_CONSTANTS

spits out:

   EPS =   2.2204460492503131E-016
 SFMIN =   2.2250738585072014E-308
 SMALL =   5.5626846462680035E-309
   BIG =   1.7976931348623157E+308

Not sure how big the impact of this is, but I suspect it's not zero?

@DeliciousHair DeliciousHair reopened this Mar 15, 2023
@DeliciousHair DeliciousHair changed the title Possible errors in some contants? Possible errors in some constants? Mar 15, 2023
@Amanieu
Copy link
Member

Amanieu commented Mar 21, 2023

I don't think these are errors. These constants come directly from the C code which was ported to Rust.

@DeliciousHair
Copy link
Author

Fair point, but all that means is that the C-code has not used the IEEE-754 standard either :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants