From 09d92f6f6da06e4e91c2487a8adb6518f18a4d12 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 29 Mar 2011 08:55:10 +0200 Subject: [PATCH] reduce the chance of rounding errors on int->float coercion --- Cython/Compiler/ExprNodes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index d90b4b17..2f51d4fb 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -861,9 +861,8 @@ class IntNode(ConstNode): return self elif dst_type.is_float: if self.constant_result is not not_a_constant: - float_value = float(self.constant_result) - return FloatNode(self.pos, value=repr(float_value), type=dst_type, - constant_result=float_value) + return FloatNode(self.pos, value='%d.0' % int(self.constant_result), type=dst_type, + constant_result=float(self.constant_result)) else: return FloatNode(self.pos, value=self.value, type=dst_type, constant_result=not_a_constant) -- 2.26.2