fixes #916
This commit is contained in:
parent
0e7220ff9c
commit
57689037c5
3 changed files with 14 additions and 5 deletions
|
|
@ -502,7 +502,7 @@ proc foldConv*(n, a: PNode; check = false): PNode =
|
|||
of tyInt..tyInt64:
|
||||
case skipTypes(a.typ, abstractRange).kind
|
||||
of tyFloat..tyFloat64:
|
||||
result = newIntNodeT(system.toInt(getFloat(a)), n)
|
||||
result = newIntNodeT(int(getFloat(a)), n)
|
||||
of tyChar: result = newIntNodeT(getOrdValue(a), n)
|
||||
else:
|
||||
result = a
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ proc opConv*(dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType): bool =
|
|||
myreset(dest); dest.kind = rkInt
|
||||
case skipTypes(srctyp, abstractRange).kind
|
||||
of tyFloat..tyFloat64:
|
||||
dest.intVal = system.toInt(src.floatVal)
|
||||
dest.intVal = int(src.floatVal)
|
||||
else:
|
||||
dest.intVal = src.intVal
|
||||
if dest.intVal < firstOrd(desttyp) or dest.intVal > lastOrd(desttyp):
|
||||
|
|
@ -338,7 +338,7 @@ proc opConv*(dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType): bool =
|
|||
myreset(dest); dest.kind = rkInt
|
||||
case skipTypes(srctyp, abstractRange).kind
|
||||
of tyFloat..tyFloat64:
|
||||
dest.intVal = system.toInt(src.floatVal)
|
||||
dest.intVal = int(src.floatVal)
|
||||
else:
|
||||
dest.intVal = src.intVal and ((1 shl (desttyp.size*8))-1)
|
||||
of tyFloat..tyFloat64:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
discard """
|
||||
file: "tints.nim"
|
||||
output: "Success"
|
||||
output: '''
|
||||
0 0
|
||||
0 0
|
||||
Success'''
|
||||
"""
|
||||
# Test the different integer operations
|
||||
|
||||
|
|
@ -41,5 +43,12 @@ test(`shl`, 0xff'i8, 0x4'i8, 0xf0'i8)
|
|||
test(`shl`, 0xffffffff'i64, 0x4'i64, 0xffffffff0'i64)
|
||||
test(`shl`, 0xffffffff'i32, 0x4'i32, 0xfffffff0'i32)
|
||||
|
||||
# bug #916
|
||||
proc unc(a: float): float =
|
||||
return a
|
||||
|
||||
echo int(unc(0.5)), " ", int(unc(-0.5))
|
||||
echo int(0.5), " ", int(-0.5)
|
||||
|
||||
echo("Success") #OUT Success
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue