#float #floating #bar #rational


Representing rational numbers using the floating-bar number type

8 releases

✓ Uses Rust 2018 edition

0.2.4 Jun 4, 2020
0.2.3 Jun 3, 2020
0.2.1 Apr 18, 2020
0.2.0 Dec 8, 2019
0.1.1 Jan 21, 2019

#206 in Data structures

46 downloads per month

0BSD license

1.5K SLoC

Floating Bar

Provides the floating-bar type, which allows for efficient representation of rational numbers without loss of precision. It is based on this blog post.

For more information, refer to the library documentation.


To use this library, add the following to your Cargo.toml:

floating_bar = "0.2.3"



This enables denormal values. When the value of the denominator takes up the whole fraction field, the numerator will take an implicit value of 1.

Due to the performance penalty of calculating with denormal values, this is disabled by default.


Pull requests welcome! There are plenty of unimplemented!() methods that one can fill in. Make sure that the documentation matches the functionality, and to add a unit test for it. If you don't wish to write a test, just add the function for it and leave it for someone else to fill it in.


This project is licensed under the BSD Zero Clause License. In general it means you can do whatever you want with it, but there are no warranties and I'm not held liable for whatever happens.