←back to thread

79 points seg_fault | 2 comments | | HN request time: 0.515s | source

Since there is so much interest on HN in floats lately and their software implementations, I wanted to show mine. It has no use and is just for teaching me floats and C++. Give me your thoughts.
Show context
amelius ◴[] No.41912300[source]
Isn't this in libgmp already?

https://gmplib.org/

replies(1): >>41912409 #
Archit3ch ◴[] No.41912409[source]
GMP doesn't do arbitrary exponents.
replies(1): >>41912498 #
amelius ◴[] No.41912498[source]
Indeed, thanks.
replies(1): >>41914101 #
1. Archit3ch ◴[] No.41914101[source]
Slight correction, while the exponent is indeed fixed, it is larger than a f32/f64 exponent: https://gmplib.org/manual/Floating_002dpoint-Functions

However, this is not exposed in all GMP wrappers.

replies(1): >>41916884 #
2. seg_fault ◴[] No.41916884[source]
If I understand this correctly GMP has a flexible mantissa with no limitations during runtime.

In fas you have to specify the sizes (of mantissa and exponent) during compile time. So the size of this type is fixed. Thus, there is no heap involved.