vax-floating - VAX Floating-Point Types
This is a Rust implementation of the VAX floating-point types documented in the VAX Architecture Reference Manual.
- Supports conversion from rust data types.
- Supports conversion from rust data types to constants.
- Supports conversion between vax floating types (both constant and runtime).
- Supports standard mathematical operators.
- Supports constant mathematical operators.
- Supports display, and lowercase and uppercase exponential output.
Features
proptest - Include support for the proptest
testing crate.
Supported VAX floating-Point Types
VAX Type | Size | Exponent size | Exponent range |
---|---|---|---|
F_floating | 32-bits | 8-bits | 2127 to 2-127 |
D_floating | 64-bits | 8-bits | 2127 to 2-127 |
G_floating | 64-bits | 11-bits | 21,023 to 2-1,023 |
H_floating | 128-bits | 15-bits | 216,383 to 2-16,383 |
Examples
use ;
use FromStr;
// Supports conversion from rust data types.
let ten = from;
let three_hundred = from;
let twelve_point_five = from;
let very_small = from_str.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Supports conversion from rust data types to constants.
const TEN: FFloating = from_u8;
const ONE_FIFTY: DFloating = from_u16;
const PI: GFloating = from_ascii;
const MANY_ZEROES: HFloating = from_u128;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Supports conversion between VAX floating point types
let ten_h = from;
let three_hundred_g = from;
let twelve_point_five_f = from;
let pi_d = from;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Supports conversion between VAX floating point types to constants
const TEN_G: GFloating = TEN.to_g_floating;
const ONE_FIFTY_H: HFloating = ONE_FIFTY.to_h_floating;
const PI_F: FFloating = PI.to_f_floating;
const MANY_ZEROES_D: DFloating = MANY_ZEROES.to_d_floating;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Supports standard mathematical operators.
let one = TEN / ten;
let four_fifty = three_hundred + ONE_FIFTY;
let two_pi = PI * from;
let many_zeroes = MANY_ZEROES - very_small;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Supports constant mathematical operators.
const TENTH: FFloating = from_u8.divide_by;
const NEG_ONE_FIFTY: DFloating = from_bits.subtract_by;
const TWO_PI: GFloating = PI.multiply_by;
const TWO_HUNDRED_NONILLION: HFloating = MANY_ZEROES.add_to;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Supports display, and lowercase and uppercase exponential output.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;