Skip to content

Commit 18d6ead

Browse files
committed
fixed sqrt() to be 100% in line with std::sqrt() - v1.0.0
1 parent 990b1ce commit 18d6ead

File tree

2 files changed

+504
-41
lines changed

2 files changed

+504
-41
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Originally I was working on a project dealing with periodic intervals, and I wan
1717
## Library cxcm
1818
[cxcm](https://github.com/davidbrowne/cxcm) is its own stand-alone project for extending ```<cmath>``` to have more functions be constexpr, targeted for ```c++20```. ```c++23``` and hopefully ```c++26``` extend the amount of functions in ```<cmath>``` to be constexpr, but this project aims to support ```c++20```.
1919

20-
There are a couple of functions where the constexpr versions are not direct replacements for the standard library versions. constexpr ```cxcm::sqrt()``` should be a 100% match to ```std::sqrt()``` when the type is ```float```, but when the type is ```double``` we get ~75.6% the same results, with the remaining results only 1 ulp away from the answer given by the standard library. Similarly, for the function constexpr ```cxcm::rsqrt()```, which is not in ```<cmath>``` but is the same as ```1 / sqrt()```, there is a 100% match for ```float``` and ```1.0f / std::sqrt(float_value)```. For ```double```, we get ~85.7% the same results as ```1.0 / std::sqrt(double_value)```, with the remaining results either within 1 ulp (~12.4%) or 2 ulps (~1.9%).
21-
2220
## cxcm Free Functions
2321

2422
Most of these constexpr functions have counterparts in [```<cmath>```](https://en.cppreference.com/w/cpp/header/cmath). Many of these functions became constexpr in ```c++23``` or ```c++26```; however, this is a ```c++20``` library, so we are stuck with doing it ourselves if we want it.
@@ -144,7 +142,7 @@ Returns ```1.0 / sqrt(value)```. Results are undefined if ```value <= 0```.
144142

145143
## Status
146144

147-
Current version: `v0.9.2`
145+
Current version: `v1.0.0`
148146

149147
Not sure yet how much more to try and make ```constexpr```. This library is meant to support the needs of other libraries, so I suppose things will be added as needed.
150148

0 commit comments

Comments
 (0)