From: Luca Bruno Date: Thu, 11 Mar 2010 11:10:03 +0000 (+0100) Subject: Use fmod/fmodf for modulo operation between floating point values X-Git-Tag: 0.8.0~163 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b358f3e4da2c59af2b7757db686935a37738a16;p=thirdparty%2Fvala.git Use fmod/fmodf for modulo operation between floating point values Fixes bug 610660. --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index fe9d70e0c..c7c6f81ec 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -4415,7 +4415,23 @@ internal class Vala.CCodeBaseModule : CCodeModule { } else if (expr.operator == BinaryOperator.DIV) { op = CCodeBinaryOperator.DIV; } else if (expr.operator == BinaryOperator.MOD) { - op = CCodeBinaryOperator.MOD; + if (expr.value_type.equals (double_type)) { + source_declarations.add_include ("math.h"); + var ccall = new CCodeFunctionCall (new CCodeIdentifier ("fmod")); + ccall.add_argument (cleft); + ccall.add_argument (cright); + expr.ccodenode = ccall; + return; + } else if (expr.value_type.equals (float_type)) { + source_declarations.add_include ("math.h"); + var ccall = new CCodeFunctionCall (new CCodeIdentifier ("fmodf")); + ccall.add_argument (cleft); + ccall.add_argument (cright); + expr.ccodenode = ccall; + return; + } else { + op = CCodeBinaryOperator.MOD; + } } else if (expr.operator == BinaryOperator.SHIFT_LEFT) { op = CCodeBinaryOperator.SHIFT_LEFT; } else if (expr.operator == BinaryOperator.SHIFT_RIGHT) {