HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.21k stars 658 forks source link

Fix broken % operator for javascript backend #3003

Closed agentultra closed 10 years ago

agentultra commented 10 years ago

The % operator in Javascript is broken, see http://javascript.about.com/od/problemsolving/a/modulobug.htm

I assume this is rather well-known among Javascript apologists but I was not expecting it as a haxe user who is used to other platforms where the operator isn't broken.

It'd be nice if the js backend could insert the fix in the generated code or provide a workaround to use it explicitly.

deltaluca commented 10 years ago

The operator is not broken. This is how most every programming language defines the % operator to work for signed integers / floats. The only exception I can think of is Python

agentultra commented 10 years ago

My bad. It's remainder and not modulo.

Sent from my mobile

On May 16, 2014, at 4:50 PM, Luca Deltodesco notifications@github.com wrote:

The operator is not broken. This is how most every programming language defines the % operator to work for signed integers / floats. The only exception I can think of is Python

— Reply to this email directly or view it on GitHub.

agentultra commented 10 years ago

Turns out you can add Perl and Ruby to that list too.