Advertisement Jump to content

Floating point precision (CScriptBuilder?)

This topic is 564 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've just updated AngelScript in my project from some 2 year old version to newest. Calling CScriptBuilder::BuildModule() now changes floating point precision from one I set in my application. I set this with _controlfp_s to use lower precision. Is there any reason any part of AS or add-on should change it? Does AS require some FP precision to work correctly? Can I set it back to lower precision and not worry? Older version of AS worked with lower precision and didn't change it

Share this post

Link to post
Share on other sites

AngelScript doesn't require any specific floating point precision. I do not change the floating point precision in the AngelScript code (at least not intentionally). 

Can you locate where exactly in the code it is being changed? 

What platform are you working on? Perhaps there is something wrong in the assembler routines for supporting native calling conventions (as_callfunc_XXX). 


Share this post

Link to post
Share on other sites

I'm building for win32, and indeed it is changed somewhere in assembler. It changes in CallCDeclFunction in as_callfunc_x86. It happens in first block of assembler inside of #if defined ASM_INTEL. (when reading that assembler part, I vaguely remember seeing CLEAR_FPU_STACK mentioned somewhere before, quite possibly when I was changing that precision. Maybe that is somehow related?

EDIT: now I see it is defined in AngelScript, so I probably just visited this part of code some time ago

EDIT2: actually, I just checked my older version of AS and found "#define CLEAR_FPU_STACK emms" with commented out "#define CLEAR_FPU_STACK fninit" , which is what is used in newest version. After downloading older version, it seems that I must have changed it and memory of this is getting clearer too


Call-stack looks like this, along with some argument values if that helps (some are omitted if I see nothing readable):

CallCDeclFunction (paramSize = 8, func = StringFactory)

CallSystemFunctionNative ( = $str, obj = 0, sysFunc->hostReturnInMemory = false, retQW2 = 0, secondObj = 0)








If there is anything else that could help, let me know

Edited by valenn

Share this post

Link to post
Share on other sites

Yes, you should probably use '#define CLEAR_FPU_STACK emms'.

I would set it to emms by default except that I remember getting error reports from some people in the past when using 'emms'. In my own applications it doesn't make a difference either way, so I never could figure out why some people are getting trouble when using 'emms' rather than 'fninit'.




Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!