Skip to content

rkennedy/exact-float

Repository files navigation

Exact floating-point representations

This program takes numbers in string form, converts them to floating-point type, and then displays the exact decimal values they represent. For example:

$ exact-float 0.2
0.2 = +0.200000000000000000002710505431213761085018632002174854278564453125
0.2 = +0.200000000000000011102230246251565404236316680908203125
0.2 = +0.20000000298023223876953125

Output appears using 80-, 64-, and 32-bit float formats.

Building

To build the program, clone the repository and run autogen.sh to set up the build environment. Then run configure and make:

$ git clone https://github.com/rkennedy/exact-float.git
$ cd exact-float
$ ./autogen.sh
$ ./configure
$ make

Dependencies

This project uses Google Test and Google Mock. To build the test program, run configure with the --with-gmock option or set GMOCK_ROOT to the directory where you have Google Mock source code. (To use a version of Google Test other than what comes with Mock, use --with-gtest or set GTEST_ROOT separately.) For example:

$ ./configure --with-gmock=$HOME/src/gmock-1.7.0

Credit

Much of this code is inspired by the ExactFloatToStr_JH0 project for Delphi by John Herbster.

About

Display floating-point values as exact decimals

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published