Advertisement

bug of div operation with uint32

Started by December 15, 2010 01:16 AM
4 comments, last by loboWu 13 years, 11 months ago
try the following sample code

uint32 a=0x80000000;
uint result=a/4;

the result will be 0xE0000000;


and I am using 2.19.0,
could you tell me how to fix these bug?
Thanks

lobo
by the way,
even in the latest 2.20.1,
this bug is the same as 2.19.0
Advertisement
Sounds like it may be a bug in the compiler or the bytecode optimization. I'll investigate it.

If it is a problem in the bytecode optimization you can work around it by turning off the optimization with a call to:

engine->SetEngineProperty(asEP_OPTIMIZE_BYTECODE, false);


This should be done before the script is compiled (obviously).

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This is actually a bug that's been in the library since the beginning back in 2003. Interesting that nobody encountered it before this.

The problem is that I have only one bytecode instruction for integer divisions which is used by both signed and unsigned integers. This is obviously wrong, because the signed division rightfully gives the result 0xE0000000, but not the unsigned division.

To fix this I'll have to introduce a new bytecode instruction for unsigned integer division, and update the compiler to choose the right bytecode for the right type. It will take a few days, but I'll try to have it done before my vacation next week.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've fixed this bug in revisions 769 and 770.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thank you.
I will check that.

This topic is closed to new replies.

Advertisement