浏览代码

Merge pull request #5308 from Feoramund/fix-4565

Move negation in `internal_rat_to_float` to end of procedure
Jeroen van Rijn 3 月之前
父节点
当前提交
611390ba27
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      core/math/big/rat.odin

+ 3 - 3
core/math/big/rat.odin

@@ -378,9 +378,6 @@ internal_rat_to_float :: proc($T: typeid, z: ^Rat, allocator := context.allocato
 	}
 	
 	has_sign := a.sign != b.sign
-	defer if has_sign {
-		f = -builtin.abs(f)
-	}
 	
 	exp := alen - blen
 	a2, b2 := &Int{}, &Int{}
@@ -440,6 +437,9 @@ internal_rat_to_float :: proc($T: typeid, z: ^Rat, allocator := context.allocato
 	if math.is_inf(f, 0) {
 		exact = false
 	}
+	if has_sign {
+		f = -builtin.abs(f)
+	}
 	return
 }