Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Mel Smith" Newsgroups: comp.lang.javascript Subject: Re: Javascript Math problem Date: Sat, 28 Apr 2012 09:00:09 -0600 Lines: 29 Message-ID: References: <6507721.320.1335573024044.JavaMail.geo-discussion-forums@ynen8> X-Trace: individual.net 4PhCf472vqK72/L86qq5Lgxhevvugk1TjMCbHGoqwl96kN8CMc Cancel-Lock: sha1:jSFbeElhlKaUlOxLZZ/CEN81tzs= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Xref: csiph.com comp.lang.javascript:13670 Stefan said: > In JS, -5.5 % 3 is -2.5 ... > > In PHP, -5.5 % 3 is -2 ... > > In Python, -5.5 % 3 is 0.5 ... > > In Perl, -5.5 % 3 is 1 ... > (unless you "use integer", then it depends on the compiler) > > In C, -5.5 % 3 doesn't work at all (int only)... > (but fmod(-5.5, 3) returns -2.5) > (oh, and the behavior with negative numbers is > "implementation defined") > Stefan: ... and in my language (xHarbour -- eXtended Harbour: a language that is compiled into C functions using the old Borland BCC 5.5.1 verion in this instance), the statement and results are: nTest := -5.5 % 3 ? ntest // result -2.5 ? str(nTest) // result -2.5 -- same -Mel