#### Archived

This topic is now archived and is closed to further replies.

# Fixed point multiplication

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

## Recommended Posts

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]

##### Share on other sites
I believe the type (long double) is an 80-bit float.

Jim

##### Share on other sites
Unfortunately, printf("%d", sizeof(long double));

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

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633690
• Total Posts
3013339
×