Casting float to integer might be a good option to simulate floor function. It costs less even though not that significant. But if you think (int)x <= x, think again...
For x <= 0, (int)x >= x, eg: (int)-1.5 = -1
very simple but annoying if you don't figure it out early. Of course (int) seems to be a better 'escape' than floor(), but you should notice its behavior.
No comments:
Post a Comment