File: f16-f128-lit.rs

package info (click to toggle)
rustc-web 1.85.0%2Bdfsg3-1~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 1,759,988 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,056; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (20 lines) | stat: -rw-r--r-- 789 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Make sure negation happens correctly. Also included:
// issue: rust-lang/rust#124583
//@ run-pass

#![feature(f16)]
#![feature(f128)]

fn main() {
    assert_eq!(0.0_f16.to_bits(), 0x0000);
    assert_eq!((-0.0_f16).to_bits(), 0x8000);
    assert_eq!(10.0_f16.to_bits(), 0x4900);
    assert_eq!((-10.0_f16).to_bits(), 0xC900);
    assert_eq!((-(-0.0f16)).to_bits(), 0x0000);

    assert_eq!(0.0_f128.to_bits(), 0x0000_0000_0000_0000_0000_0000_0000_0000);
    assert_eq!((-0.0_f128).to_bits(), 0x8000_0000_0000_0000_0000_0000_0000_0000);
    assert_eq!(10.0_f128.to_bits(), 0x4002_4000_0000_0000_0000_0000_0000_0000);
    assert_eq!((-10.0_f128).to_bits(), 0xC002_4000_0000_0000_0000_0000_0000_0000);
    assert_eq!((-(-0.0f128)).to_bits(), 0x0000_0000_0000_0000_0000_0000_0000_0000);
}