Closed xgroleau closed 3 years ago
Thanks for the contribution! I would suggest to name the flag BBZ_ENABLE_FLOAT_OPERATIONS (not FLOATS). I have a couple of questions:
I would also suggest to check spaces and indent style
Thanks for the comments!
I've renamed the compilation flag.
The base define is a bad name, I've renamed it to bbzvm_operator, but I am open to renaming it again. I'll add some doc on what it does.
I wanted to modify the least amount of code for the kilobot build since I don't have a one for regression testing and see if it still fits in memory. It should still fit since the compiled code with BBZ_ENABLE_FLOAT_OPERATIONS=OFF should be exactly the same as before.
The code is inspired of the BVM here.
The define simply takes the left hand side, right hand side and applies the operator on it, with if to obtain the right value depending on the type (gets the float value if it's float, ect). Then returns a new object created with the calculated value using the provided operator. A define is used since it avoided code duplication because the code is the same for +,-,* and / though I couldn't use the define for the modulo operator since % doesn't work on float, but the code is very similar.
OK, looks good, thanks for the contribution!
A flag
BBZ_ENABLE_FLOATS_OPERATIONS
was added to enable floats manipulation in the bbvm, allowing to make use on an FPU. Power are not supported on floats as of now since it's a bit more complex to implement. I've tested it a bit on our project and all operation seems to work adequately. Comments are obviously welcomed since it's the first time I contribute to the project. Also some minor typo were corrected.