Skip to content

scoped control for turning off denormal floating point numbers

License

Notifications You must be signed in to change notification settings

Sin-tel/no_denormals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

no_denormals

build Crates.io MIT licensed

Temporarily turn off floating point denormals.

Internally, this uses a RAII-style guard to manage the state of certain processor flags. On x86 and x86_64, this sets the flush-to-zero and denormals-are-zero flags in the MXCSR register. On aarch64 this sets the flush-to-zero flag in the FPCR register. In all cases, the register will be reset to its initial state when the guard is dropped.

Note that according to the Rust docs "modifying the masking flags, rounding mode, or denormals-are-zero mode flags leads to immediate Undefined Behavior: Rust assumes that these are always in their default state and will optimize accordingly." So use this at your own risk.

Usage

use no_denormals::no_denormals;

unsafe {
    no_denormals(|| {
        // your DSP code here.
    })
};

About

scoped control for turning off denormal floating point numbers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages