Skip to content

Slight rounding errors in constants #3145

Open
@jachymb

Description

@jachymb

In constants.hpp, I noticed there are some constants that get a small unnecessary rounding error due to how they are defined.

For example, with 64bit precision floating point, we have:

LOG_TWO_PI = LOG_TWO + LOG_PI = 0.6931471805599453 + 1.1447298858494002 =
1.8378770664093453

However, a mathematically more precise value is $\log(2\pi) \approx 1.83787706640934548356065947281123527972279494727556682563430308096553139185$

This is better rounded to the 64bit value

1.8378770664093456

which means the current value has an unnecessary error in the order of E-16.

I guess there could be a similar type of issue for other constants as well.

I suppose this is pretty much negligible for any practical purpose and perhaps one may argue the current implementation is better readable. But my OCD is kinda forcing me to point this out haha

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions