#float #convert #floating-point #string #algorithm #display #ftoa

schubfach

Schubfach algorithm for floating-point to string conversion

1 unstable release

0.0.1 Mar 10, 2023

#123 in #float

Download history 71/week @ 2024-07-27 61/week @ 2024-08-03 66/week @ 2024-08-10 21/week @ 2024-08-17 28/week @ 2024-08-24 2/week @ 2024-08-31 124/week @ 2024-09-07 40/week @ 2024-09-14 61/week @ 2024-09-21 32/week @ 2024-09-28 90/week @ 2024-10-05 90/week @ 2024-10-12 143/week @ 2024-10-19 43/week @ 2024-10-26 32/week @ 2024-11-02 38/week @ 2024-11-09

267 downloads per month

MIT license

155KB
2K SLoC

schubfach

crate documentation crate


Schubfach algorithm

This is a Rust implementation of the Schufbach algorithm that converts IEEE-754 double-precision floating-point values to their string decimal representation.

It is performant and has a relatively small footprint. For performance comparisons, check the Drachennest project or the Dragonbox project.

Status

WARNING! This is very much work-in-progress.

The code is functional but must still be more thoroughly tested and optimized. The API is not considered as definitive yet, not is the code architecture.

Current features:

  • double-precision values (f64) are supported
  • a simple function converts values to a simple string format, either fixed or scientific depending on the value
  • a more complex function offers more choices, like
    • fixed / scientific format selection
    • precision
    • correct rounding to even
    • interface through method or Display trait

Planned features:

  • engineering format

References

The algorithm is described by its author in the following article:

The author made a Java implementation:

The Rust code is mainly a translation from Alexander Bolz's C++ implementation:

  • https://github.com/abolz/Drachennest

    with the following licence:

    Copyright 2020 Alexander Bolz
    
    Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at 
      https://www.boost.org/LICENSE_1_0.txt)
    

Compatibility

The schubfach crate is tested for rustc 1.68 and greater, on Windows 64-bit and Linux 64/32-bit platforms. There shouldn't be any problem with older versions.

License

Licensed under MIT license.

Dependencies