Giter Club home page Giter Club logo

const_soft_float's Introduction

Rust float-point in constant context

Floating-point code is from compiler_builtins = "0.1.94" and libm = "0.2.6", and has been rewritten for use in a constant context.

Fuzzing of all operations is performed against the relevant reference code to ensure correctness of the port, but please open an issue if there is any inconsistent behavior.

Exported Soft Float Types:

  • SoftF32
  • SoftF64

Features:

  • no_std - Enabled by default
  • const_trait_impl - For const operator implementations
  • const_mut_refs - For const operator with assignment implementations

On stable:

const fn const_f32_add(a: f32, b: f32) -> f32 {
    SoftF32(a).add(SoftF32(b)).to_f32()
}

On nightly with const_trait_impl usage:

const fn const_f32_add(a: f32, b: f32) -> f32 {
    (SoftF32(a) + SoftF32(b)).to_f32()
}

On nightly with const_mut_refs usage:

const fn const_f32_add(a: f32, b: f32) -> f32 {
    let mut x = SoftF32(a);
    x += SoftF32(b);
    x.to_f32()
}

Implemented const Functions:

  • from_(f32/f64)
  • to_(f32/f64)
  • from_bits
  • to_bits
  • add
  • sub
  • mul
  • div
  • cmp
  • neg
  • sqrt
  • powi
  • copysign
  • trunc
  • round
  • floor
  • sin
  • cos

const_soft_float's People

Contributors

823984418 avatar elpiel avatar knickish avatar zredshift avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

const_soft_float's Issues

Parity

Missing a couple methods for parity between SoftF32 and SoftF64:

  • SoftF32::powf
  • SoftF32::is_nan
  • SoftF32::max
  • SoftF32::min
  • SoftF32::exp
  • SoftF32::ln

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.