mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 15:39:06 +01:00
add ability to do into int on floats using a radix (#6033)
This commit is contained in:
parent
c2f8f4bd9b
commit
ad9449bf00
@ -169,7 +169,32 @@ pub fn action(input: &Value, span: Span, radix: u32, little_endian: bool) -> Val
|
||||
}
|
||||
Value::Filesize { val, .. } => Value::Int { val: *val, span },
|
||||
Value::Float { val, .. } => Value::Int {
|
||||
val: *val as i64,
|
||||
val: {
|
||||
if radix == 10 {
|
||||
*val as i64
|
||||
} else {
|
||||
match convert_int(
|
||||
&Value::Int {
|
||||
val: *val as i64,
|
||||
span,
|
||||
},
|
||||
span,
|
||||
radix,
|
||||
)
|
||||
.as_i64()
|
||||
{
|
||||
Ok(v) => v,
|
||||
_ => {
|
||||
return Value::Error {
|
||||
error: ShellError::UnsupportedInput(
|
||||
"Could not convert float to integer".to_string(),
|
||||
span,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
span,
|
||||
},
|
||||
Value::String { val, .. } => {
|
||||
|
Loading…
Reference in New Issue
Block a user