Skip to main content
gamedev.net
🔒 Locked

Fixed point multiplication

Started by Krylloan 1 reply 400+ views
Original Post
Krylloan
Krylloan
I want to use 2 types of fixed point variables a) 32b.32b b) 0b.64b I want to represent them using signed __int64; Is there a fast way to multiply a * a or b * b without losing any accuracy? Like:
      
__int64 aprod = __int64(( __int128(ax) * __int128(ax) ) >> 64);
__int64 bprod = __int64(( __int128(bx) * __int128(by) ) >> 32);
//where aprod, ax and ay are 32b.32b

//where bprod, bx and by are 0b.64b

  
Which would work perfectly if only __int128 existed. (ps, whatever happed to extended 80-bit floats) Any ideas? (I'm currently using an inline function) [/source] [edited by - Krylloan on August 11, 2002 3:13:03 PM] [edited by - Krylloan on August 11, 2002 3:13:38 PM]
Jim_
Jim_
I believe the type (long double) is an 80-bit float.

Jim
Krylloan
Krylloan
Unfortunately, printf("%d", sizeof(long double));

returns "8" (64bit) with MSVC 6.0. Although I thought it used to be 80, also.


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.