From d23929fc8099f25d99420f78f85938f649eadf19 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Fri, 5 Nov 2021 07:04:02 +1300 Subject: [PATCH] Update mode.rs trying a switch to native endian --- crates/nu-command/src/math/mode.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/nu-command/src/math/mode.rs b/crates/nu-command/src/math/mode.rs index b3eb646b16..baa8f2e739 100644 --- a/crates/nu-command/src/math/mode.rs +++ b/crates/nu-command/src/math/mode.rs @@ -90,15 +90,15 @@ pub fn mode(values: &[Value], head: &Span) -> Result { let hashable_values: Result, ShellError> = values .iter() .map(|val| match val { - Value::Int { val, .. } => Ok(HashableType::new(val.to_be_bytes(), NumberTypes::Int)), + Value::Int { val, .. } => Ok(HashableType::new(val.to_ne_bytes(), NumberTypes::Int)), Value::Duration { val, .. } => { - Ok(HashableType::new(val.to_be_bytes(), NumberTypes::Duration)) + Ok(HashableType::new(val.to_ne_bytes(), NumberTypes::Duration)) } Value::Float { val, .. } => { - Ok(HashableType::new(val.to_be_bytes(), NumberTypes::Float)) + Ok(HashableType::new(val.to_ne_bytes(), NumberTypes::Float)) } Value::Filesize { val, .. } => { - Ok(HashableType::new(val.to_be_bytes(), NumberTypes::Filesize)) + Ok(HashableType::new(val.to_ne_bytes(), NumberTypes::Filesize)) } other => Err(ShellError::UnsupportedInput( "Unable to give a result with this input".to_string(), @@ -143,19 +143,19 @@ fn recreate_value(hashable_value: &HashableType, head: Span) -> Value { let bytes = hashable_value.bytes; match &hashable_value.original_type { NumberTypes::Int => Value::Int { - val: i64::from_be_bytes(bytes), + val: i64::from_ne_bytes(bytes), span: head, }, NumberTypes::Float => Value::Float { - val: f64::from_be_bytes(bytes), + val: f64::from_ne_bytes(bytes), span: head, }, NumberTypes::Duration => Value::Duration { - val: i64::from_be_bytes(bytes), + val: i64::from_ne_bytes(bytes), span: head, }, NumberTypes::Filesize => Value::Filesize { - val: i64::from_be_bytes(bytes), + val: i64::from_ne_bytes(bytes), span: head, }, }