Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2f159b

Browse files
committed
Formatted code files
1 parent54d5869 commitc2f159b

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

‎jit/src/instructions.rs‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -449,27 +449,33 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
449449
}
450450

451451
// Floats and Integers
452-
(_,JitValue::Int(a),JitValue::Float(b)) |
453-
(_,JitValue::Float(a),JitValue::Int(b)) =>{
454-
452+
(_,JitValue::Int(a),JitValue::Float(b))
453+
|(_,JitValue::Float(a),JitValue::Int(b)) =>{
455454
let operand_one =match a_type.unwrap(){
456455
JitType::Int =>self.builder.ins().fcvt_from_sint(types::F64, a),
457-
_=> a
456+
_=> a,
458457
};
459458

460459
let operand_two =match b_type.unwrap(){
461460
JitType::Int =>self.builder.ins().fcvt_from_sint(types::F64, b),
462-
_=> b
461+
_=> b,
463462
};
464463

465-
match op{
466-
BinaryOperator::Add =>JitValue::Float(self.builder.ins().fadd(operand_one, operand_two)),
467-
BinaryOperator::Subtract =>JitValue::Float(self.builder.ins().fsub(operand_one, operand_two)),
468-
BinaryOperator::Multiply =>JitValue::Float(self.builder.ins().fmul(operand_one, operand_two)),
469-
BinaryOperator::Divide =>JitValue::Float(self.builder.ins().fdiv(operand_one, operand_two)),
470-
_ =>returnErr(JitCompileError::NotSupported)
464+
match op{
465+
BinaryOperator::Add =>{
466+
JitValue::Float(self.builder.ins().fadd(operand_one, operand_two))
467+
}
468+
BinaryOperator::Subtract =>{
469+
JitValue::Float(self.builder.ins().fsub(operand_one, operand_two))
470+
}
471+
BinaryOperator::Multiply =>{
472+
JitValue::Float(self.builder.ins().fmul(operand_one, operand_two))
473+
}
474+
BinaryOperator::Divide =>{
475+
JitValue::Float(self.builder.ins().fdiv(operand_one, operand_two))
476+
}
477+
_ =>returnErr(JitCompileError::NotSupported),
471478
}
472-
473479
}
474480
_ =>returnErr(JitCompileError::NotSupported),
475481
};

‎jit/tests/float_tests.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ fn test_mul_with_integer() {
105105
assert_approx_eq!(mul(5.2,2),Ok(10.4));
106106
assert_approx_eq!(mul(3.4, -1),Ok(-3.4));
107107
assert_bits_eq!(mul(1.0,0),Ok(0.0f64));
108-
assert_bits_eq!(mul(-0.0,1),Ok(-0.0f64));
108+
assert_bits_eq!(mul(-0.0,1),Ok(-0.0f64));
109109
assert_bits_eq!(mul(0.0, -1),Ok(-0.0f64));
110-
assert_bits_eq!(mul(-0.0,-1),Ok(0.0f64));
110+
assert_bits_eq!(mul(-0.0,-1),Ok(0.0f64));
111111
}
112112

113113
#[test]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp