summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semfold.nim2
-rw-r--r--compiler/vm.nim4
-rw-r--r--tests/misc/tints.nim13
3 files changed, 14 insertions, 5 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim
index 76ac23e0d..ba7f3cabd 100644
--- a/compiler/semfold.nim
+++ b/compiler/semfold.nim
@@ -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
diff --git a/compiler/vm.nim b/compiler/vm.nim
index f75db56b8..3d2ddfc82 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -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:
diff --git a/tests/misc/tints.nim b/tests/misc/tints.nim
index 3e413026a..ded24fb5c 100644
--- a/tests/misc/tints.nim
+++ b/tests/misc/tints.nim
@@ -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