mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
* avoid #8231, bitwise move to mul,div * add test for #8231 * fix bitwise move when div result is float * bitwise move depends on typ.size
This commit is contained in:
@@ -602,8 +602,16 @@ proc arithAux(p: PProc, n: PNode, r: var TCompRes, op: TMagic) =
|
||||
of mMulF64: applyFormat("($1 * $2)", "($1 * $2)")
|
||||
of mDivF64: applyFormat("($1 / $2)", "($1 / $2)")
|
||||
of mShrI: applyFormat("", "")
|
||||
of mShlI: applyFormat("($1 << $2)", "($1 << $2)")
|
||||
of mAshrI: applyFormat("($1 >> $2)", "($1 >> $2)")
|
||||
of mShlI:
|
||||
if n[1].typ.size <= 4:
|
||||
applyFormat("($1 << $2)", "($1 << $2)")
|
||||
else:
|
||||
applyFormat("($1 * Math.pow(2,$2))", "($1 * Math.pow(2,$2))")
|
||||
of mAshrI:
|
||||
if n[1].typ.size <= 4:
|
||||
applyFormat("($1 >> $2)", "($1 >> $2)")
|
||||
else:
|
||||
applyFormat("Math.floor($1 / Math.pow(2,$2))", "Math.floor($1 / Math.pow(2,$2))")
|
||||
of mBitandI: applyFormat("($1 & $2)", "($1 & $2)")
|
||||
of mBitorI: applyFormat("($1 | $2)", "($1 | $2)")
|
||||
of mBitxorI: applyFormat("($1 ^ $2)", "($1 ^ $2)")
|
||||
|
||||
3
tests/js/t8231.nim
Normal file
3
tests/js/t8231.nim
Normal file
@@ -0,0 +1,3 @@
|
||||
import strutils
|
||||
|
||||
doAssert formatSize(2462056448, '.', bpIEC, false) == "2.293GiB"
|
||||
Reference in New Issue
Block a user