Difference between revisions of "Talk:Function for Time of Day"
imported>Daemonjax (educated guess) |
imported>Daemonjax |
||
Line 5: | Line 5: | ||
-- [[User:Cipscis|Cipscis]] 15:43, 22 February 2012 (EST) | -- [[User:Cipscis|Cipscis]] 15:43, 22 February 2012 (EST) | ||
True, it's an educated guess. Floor() functions (and to a certain extent entire Math libraries)are notoriously slow in all languages, because they have to return correctly in all circumstances. The int cast will work in this case, because: 1) the number of game days passed should never exceed to max value of an integer, and 2) The number of game days passed will always be a positive number. | True, it's an educated guess. Floor() functions (and to a certain extent entire Math libraries) are notoriously slow in all languages, because they have to return correctly in all circumstances. The int cast will work in this case, because: 1) the number of game days passed should never exceed to max value of an integer, and 2) The number of game days passed will always be a positive number. | ||
If you would find the results interesting, I could write a script that runs a test ingame. :D | If you would find the results interesting, I could write a script that runs a test ingame. :D | ||
-- [[User:Daemonjax|Daemonjax]] | -- [[User:Daemonjax|Daemonjax]] |
Revision as of 00:35, 23 February 2012
Casting float to int faster than Math.Floor
I'd be very interested to know where this came from. Was there a test that was run, or is it just an educated guess based on the performance of other languages? If there was a test, I'd be really interested in the details of how it was run and what its results were.
-- Cipscis 15:43, 22 February 2012 (EST)
True, it's an educated guess. Floor() functions (and to a certain extent entire Math libraries) are notoriously slow in all languages, because they have to return correctly in all circumstances. The int cast will work in this case, because: 1) the number of game days passed should never exceed to max value of an integer, and 2) The number of game days passed will always be a positive number.
If you would find the results interesting, I could write a script that runs a test ingame. :D
-- Daemonjax