Re: remainder() is not right
- Posted by CChris <christian.cuvier at agriculture.g??v.fr> May 05, 2008
- 1075 views
Euler German wrote: > > > On 4 May 2008 at 16:40, CChris wrote (maybe snipped): > > > It returns *a* emainder. When a and b are positive, this is the > > expected value. When signs are otherwise, then a discrepancy appears > > with what, in arithmetic, is called "remainder". > > > > Please, I'm not discussing mathematical discrepancies. I only stated > that remainder(), as described in reference manual, works as said, > thus returning the "left over" of a division, so it can't be told > wrong. I'm NOT saying there's no need for a "signed_remainder()", > though I have no use for it. YMMV. > > Some quick explanation at: > - <a > href="http://en.wikipedia.org/wiki/Remainder">http://en.wikipedia.org/wiki/Remainder</a> > - <a > href="http://en.wikipedia.org/wiki/Modulo_operation">http://en.wikipedia.org/wiki/Modulo_operation</a> > > IMO you're describing a modulo function (or operator) so, if we had > something like: > > m = mod(x, y) this would be in Euphoria as: > > }}} <eucode> > m = x - y * floor(x / y) > </eucode> {{{ > > ...and produces those same results you claim. > > Best, > Euler > > PS: This message was sent earlier but didn't find a safe way to the > list. Maybe munged headers and body. Sorry if you're getting this > twice. > > -- > _ > _| euler f german > _| sete lagoas, mg, brazil > _| efgerman{AT}gmail{DOT}com > _| ----------------------------- > _| Reply preferably to the list, > _| or to the address above. Thx! > > Ok for mod() or modulo(), and the formula would be right. Since that's what I mostly need, I have learned not to use remainder() but when both operands are above 0 (with extension to sequences). CChris