Number-to-ByteVector-conversion #44
1 changed files with 4 additions and 3 deletions
|
|
@ -406,7 +406,7 @@ impl VM {
|
||||||
n.0 > u8::MAX.into() || n.0 < 0.0 {
|
n.0 > u8::MAX.into() || n.0 < 0.0 {
|
||||||
e!("input to NTOBV cannot cleanly convert");
|
e!("input to NTOBV cannot cleanly convert");
|
||||||
}
|
}
|
||||||
Datum::ByteVector(n.0.to_bits().to_be_bytes().to_vec()).into()
|
Datum::ByteVector(n.0.to_bits().to_ne_bytes().to_vec()).into()
|
||||||
} else {
|
} else {
|
||||||
e!("illegal argument to NTOBV instruction");
|
e!("illegal argument to NTOBV instruction");
|
||||||
}
|
}
|
||||||
|
|
@ -1111,6 +1111,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn isa_conversions() {
|
fn isa_conversions() {
|
||||||
let mut vm = VM::from(Program(vec![], vec![
|
let mut vm = VM::from(Program(vec![], vec![
|
||||||
|
|
||||||
// load from stack into expr
|
// load from stack into expr
|
||||||
Instruction(i::DUPL, vec![Operand(Address::Stack, 0),
|
Instruction(i::DUPL, vec![Operand(Address::Stack, 0),
|
||||||
Operand(Address::Expr, 0)]),
|
Operand(Address::Expr, 0)]),
|
||||||
|
|
@ -1120,7 +1121,6 @@ mod tests {
|
||||||
Instruction(i::PUSH, vec![Operand(Address::Expr, 0)]),
|
Instruction(i::PUSH, vec![Operand(Address::Expr, 0)]),
|
||||||
|
|
||||||
// reset expr to original char
|
// reset expr to original char
|
||||||
|
|
||||||
Instruction(i::DUPL, vec![Operand(Address::Stack, 1),
|
Instruction(i::DUPL, vec![Operand(Address::Stack, 1),
|
||||||
Operand(Address::Expr, 0)]),
|
Operand(Address::Expr, 0)]),
|
||||||
|
|
||||||
|
|
@ -1158,7 +1158,8 @@ mod tests {
|
||||||
(2, Datum::Number(Number::Flt(Float(97.0))).into()),
|
(2, Datum::Number(Number::Flt(Float(97.0))).into()),
|
||||||
(3, Datum::Number(Number::Fra(Fraction(97, 1))).into()),
|
(3, Datum::Number(Number::Fra(Fraction(97, 1))).into()),
|
||||||
(4, Datum::String(vec![b'a']).into()),
|
(4, Datum::String(vec![b'a']).into()),
|
||||||
(5, Datum::Char(b'a').into()),
|
(5, Datum::Number(Number::Fra(Fraction(97, 1))).into()),
|
||||||
|
(6, Datum::Char(b'a').into()),
|
||||||
],
|
],
|
||||||
syms: vec![],
|
syms: vec![],
|
||||||
errr: None,
|
errr: None,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue