Jump to content

"fixed" arithmetic


Recommended Posts

Because operations don't work. F.e. take multiplication. Take (as a small example, I won't write out 32 bits) it's stored in 8 bits, of which 1 bit is for the sign 4 are for the integer value, and 3 for the decimal places. Then 1 is represented as 1000 in binary, so 1*1 integer multiplication is 1000000 = 16. Doesn't really work out eh?

The functions made available in CFixed make sure the numbers get shifted to one side or the other so these operations do make sense (and take into account unexpected overflows). It's just easier when you can do a*b with fixed numbers, and let it give the correct result. Instead of calling some method mult() defined in an obscure place.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...