Re: remainder() is not right
- Posted by "Euler German" <eulerg at gmail.com> May 05, 2008
- 1080 views
> On 5 May 2008 at 8:41, Matt Lewis wrote (maybe snipped): > Euler German wrote: > > > > If I got the idea right, this has to do with de *ability* to convert > > Euphoria code into C. The modulo operator in C doesn't behave > > exactly the same way depending of the compiler and hardware. Seems > > they "fixed" it after ISO 1999. In a 100% Euphoria world remainder() > > should suffice, but after translated into C would it produce the > > same result? > > This wouldn't be an issue. If it's all euphoria, then, obviously, it > would work the same. If it's implemented in the backend as part of > the runtime, it would still use that same code, rather than simply > calling a C runtime library function. > > Matt > Maybe I didn't express myself clearly. What I mean is that an Euphoria program translated into C and compiled by a C compiler could produce different results depending on the C compiler and/or the hardware used. I was thinking on what Ricardo Forno said about it: <rf> More on the subject. In C, there are two ways to get an integer quotient: q = floor(a /(double)b); and q = (int)(a / (double)b); For negative "a", they give different results. </rf> Hope it make sense now. :) Best, Euler -- _ _| euler f german _| sete lagoas, mg, brazil _| efgerman{AT}gmail{DOT}com