View Single Post
Old 10th April 2018, 15:58   #24
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 856
Quote:
There's also & for bitwise AND.
Alright, I never considered bitwise operators because the internal representation of numbers in MD is not quite clear to me, i.e. whether a number is represented as float or integer. Judged by rounding error, it appears that MD converts integers into floats very quickly; it would be useful for some purposes to force integer during calculations but I don't think it is possible.
Doing bitwise operation on a float will produce rather garbage if applied straightaway, e.g. to an IEEE float representation. But it seems that MD is not quite stupid and in such cases does a float->integer conversion first. In your 0|x construct, the 0 does nothing apparently, but the bit operator tells MD to use integers. 0|x appears to be equivalent to int(x).

The snake is not moving continuously; shouldn't it ? It rather goes step by step, and sometimes makes long pauses. Heck, what protracted code... I understand that you need collision detection and what not, but have you considered to proceed the snake in the megabuf simply by a memory copy e.g. memcpy (destination, source, number_of_values)?
Nitorami is offline   Reply With Quote