equation type
I don't understand the type of temp var.
ex:
I register a collection of formatted functions.
r = engine->RegisterObjectMethod("string", "string@ formatted(const string& in, const int)", asMETHOD(asString, formattedINT), asCALL_THISCALL); ASSERT( r >= 0 );
r = engine->RegisterObjectMethod("string", "string@ formatted(const string& in, const float)", asMETHOD(asString, formattedFLOAT), asCALL_THISCALL); ASSERT( r >= 0 );
r = engine->RegisterObjectMethod("string", "string@ formatted(const string& in, const uint)", asMETHOD(asString, formattedUINT), asCALL_THISCALL); ASSERT( r >= 0 );
r = engine->RegisterObjectMethod("string", "string@ formatted(const string& in, const double)", asMETHOD(asString, formattedDOUBLE), asCALL_THISCALL); ASSERT( r >= 0 );
and in script:
formatted("%.0f", int(5-10)*(100/255.0)); ==> -2, right!
formatted("%.0f", (5-10)*(100/255.0)); ==> 1684300898, error!
formatted("%.0f", float(5-10)*(100/255.0)); ==> 1684300898, error!
formatted("%.0f", double(5-10)*(100/255.0)); ==> 1684300898, error!
formatted("%.0f", float(-5)*(100/255.0)); ==> -2, right!
that is , the temp variable is always use uint to reserve the value,
and the double(), float() constructor doesn't convert it to signed value.
These behavior of type conversion make me confused.
Interesting, the simplest angelscript code could demo this is like this:
It seems a issue in asCCompiler::CompileMathOperator(...)in as_compiler.cpp:
// as codevoid fun(){ float tmp = float(5-10);}
It seems a issue in asCCompiler::CompileMathOperator(...)in as_compiler.cpp:
asCCompiler::CompileMathOperator(...)... if( lctx->type.dataType.IsIntegerType() || lctx->type.dataType.IsUnsignedType() ) { if( lctx->type.dataType.GetSizeInMemoryDWords() == 1 ) { int v = 0; if( op == ttPlus ) v = lctx->type.intValue + rctx->type.intValue; else if( op == ttMinus ) v = lctx->type.intValue - rctx->type.intValue; else if( op == ttStar ) v = lctx->type.intValue * rctx->type.intValue; else if( op == ttSlash ) { if( rctx->type.intValue == 0 ) v = 0; else v = lctx->type.intValue / rctx->type.intValue; } else if( op == ttPercent ) { if( rctx->type.intValue == 0 ) v = 0; else v = lctx->type.intValue % rctx->type.intValue; } // v's value is -5, it is an Integer, so ctx->type should be Integer and // v should assign to ctx->type.intValue, // but here it is set to Unsigned Integer ctx->type.SetConstantDW(lctx->type.dataType, v); }...
I'll have this fixed as soon as possible, hopefully this weekend. Thanks for the report.
Regards,
Andreas
Regards,
Andreas
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 now. You may find the fix in version 2.13.1 that I just uploaded.
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 topic is closed to new replies.
Advertisement
Popular Topics
Advertisement