I've realized that if b/c is e.g. half of a negative integer then the above two do not give the same result. (although perhaps they should? at least for me that would be logical) the reason is that // rounds 'towards 0' and not 'to the lower value'.
in this case in the docs it should be made more clear: https://wiki.gideros.rocks/index.php/Integer_Divide_Operator in particular here: a=b//c -- faster than a=math.floor(b/c) could be replaced by a=b//c -- faster than a=math.floor(b/c) and the same if b/c is positive
btw then i guess if i need math.floor(b/c) also for negative numbers, then i cannot make it faster using // somehow?
Yes, it will be equivalent to math.floor for positive numbers and math.ceil for negative numbers. If you want an equivalent to math.floor for negative numbers, then you could try something like
Comments
https://wiki.gideros.rocks/index.php/Integer_Divide_Operator
in particular here:
a=b//c -- faster than a=math.floor(b/c)
could be replaced by
a=b//c -- faster than a=math.floor(b/c) and the same if b/c is positive
btw then i guess if i need math.floor(b/c) also for negative numbers, then i cannot make it faster using // somehow?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: keszegh
Fragmenter - animated loop machine and IKONOMIKON - the memory game