HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.98k stars 439 forks source link

replace Math.floor() with Std.int() #240

Closed Beeblerox closed 11 years ago

Beeblerox commented 11 years ago

Std.int() is much faster on flash target, and slightly faster on cpp

impaler commented 11 years ago

I didn't realize they did exactly the same thing. I just tested it and Mode demo is working for neko, windows and flash. Idea says 329 usages, do you want me to push this find and replace?

Beeblerox commented 11 years ago

@impaler I would be grateful if you will do this

sergey-miryanov commented 11 years ago

For negative numbers functions return different result. So please don't do this before new release without careful testing. 17.02.2013 17:08 пользователь "Zaphod" notifications@github.com написал:

@impaler https://github.com/impaler I would be grateful if you will do this

— Reply to this email directly or view it on GitHubhttps://github.com/Beeblerox/HaxeFlixel/issues/240#issuecomment-13684220.

Beeblerox commented 11 years ago

@sergey-miryanov ok, i'll do it only for variables which should have only positive values

impaler commented 11 years ago

@sergey-miryanov thanks, I can see a minor difference.

var PositiveNumber = 6534838684568.43623634263246;
var Negativenumber = - 6534838684568.43623634263246;

nme.Lib.trace( "positive:Std.int: " + Std.int(PositiveNumber));
nme.Lib.trace( "positive:Math.floor: " + Math.floor(PositiveNumber));

nme.Lib.trace( "negative:Std.int: " + Std.int(Negativenumber));
nme.Lib.trace( "negative:Math.floor: " + Math.floor(Negativenumber));

//flash
[trace] positive:Std.int:       -2101539944
[trace] positive:Math.floor: -2101539944
[trace] negative:Std.int:       2101539944
[trace] negative:Math.floor: 2101539943

//neko
Lib.hx:246: positive:Std.int: 45943704
Lib.hx:246: positive:Math.floor: 45943704
Lib.hx:246: negative:Std.int: -45943704
Lib.hx:246: negative:Math.floor: -45943705

//windows
Lib.hx:246: positive:Std.int: -2101539944
Lib.hx:246: positive:Math.floor: -2101539944
Lib.hx:246: negative:Std.int: 2101539944
Lib.hx:246: negative:Math.floor: 2101539943
Beeblerox commented 11 years ago

started in commit 5d3415d602

sergey-miryanov commented 11 years ago

Huge work! Looks ok.

Beeblerox commented 11 years ago

yeah, i've done this only in cases where i was 100% sure