Skip to content

Commit

Permalink
Merge pull request #32 from dmiller15/dm-fix-missing-floats
Browse files Browse the repository at this point in the history
🐛 report BCF2 missing floats
  • Loading branch information
brentp authored Sep 26, 2023
2 parents b05183b + 30ab0de commit de24339
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ fasteval = { version = "0.2.4", features = ["unsafe-vars"] }
bincode = { version = "1.3.3" }
json5 = "0.4.1"

ieee754 = "0.2"

[profile.release]
lto = "fat"
codegen-units = 1
6 changes: 4 additions & 2 deletions src/lib/echtvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use std::io::BufReader;

use stream_vbyte::{decode::decode, x86::Ssse3};

use ieee754::Ieee754;

#[derive(Debug, Clone, Copy)]
pub enum Value {
Int(i32),
Expand Down Expand Up @@ -294,7 +296,7 @@ impl EchtVars {
fn get_float_value(self: &EchtVars, fld: &fields::Field, idx: usize) -> f32 {
let v: u32 = self.values[fld.values_i][idx];
return if v == u32::MAX {
fld.missing_value as f32
if fld.missing_value == 0x7F800001 { Ieee754::from_bits(0x7F800001) } else { fld.missing_value as f32 }
} else {
if fld.zigzag {
(zigzag::decode(v) as f32) / (fld.multiplier as f32)
Expand Down Expand Up @@ -369,7 +371,7 @@ impl EchtVars {
self.evalues[fld.values_i] = Value::Int(val);
expr_values[fld.values_i] = val as f64
} else if fld.ftype == fields::FieldType::Float {
let val = fld.missing_value as f32;
let val = if fld.missing_value == 0x7F800001 { Ieee754::from_bits(0x7F800001) } else { fld.missing_value as f32 };
self.evalues[fld.values_i] = Value::Float(val);
expr_values[fld.values_i] = val as f64
}
Expand Down

0 comments on commit de24339

Please sign in to comment.