7 releases
Uses old Rust 2015
0.1.3 | Mar 8, 2015 |
---|---|
0.1.2 | Jan 9, 2015 |
0.0.4 |
|
0.0.3 | Nov 27, 2014 |
#40 in #hex-string
8KB
125 lines
hexfloat
A Rust syntax extension to create floating point literals from hexadecimal strings.
Usage
Add this to your Cargo.toml
:
[dependencies]
hexfloat = "*"
and this to your crate root:
#![feature(phase)]
#[phase(plugin)]
extern crate hexfloat;
lib.rs
:
Syntax extension to create floating point literals from hexadecimal strings
Once loaded, hexfloat!() is called with a string containing the hexadecimal floating-point literal, and an optional type (f32 or f64). If the type is omitted, the literal is treated the same as a normal unsuffixed literal.
Examples
To load the extension and use it:
#[phase(plugin)]
extern crate hexfloat;
fn main() {
let val = hexfloat!("0x1.ffffb4", f32);
}
References
- [ExploringBinary: hexadecimal floating point constants] (http://www.exploringbinary.com/hexadecimal-floating-point-constants/)