flat assembler
Message board for the users of flat assembler.
Index
> Heap > [ARTICLE] Fixed point info and tricks 
Author 

Borsuc
There has been some time since I was on the net, and I decided to write an article which I hope will make you understand fixed point, the difference between it and floating point, and how both are just "emulations" of 'real' numbers.
I see some people get confused at the "multiplication by the reciprocal" in integer arithmetic. Don't worry, that's actually a fixed point trick. I hope the article explains it well enough. But of course the list is much longer  fixed point is certainly lowlevel mathoriented, but math is still math Of course the article might contain errors (especially in the floating point info). Thanks to revolution for explaining float a while back (I looked so dumb back then ). That's why I post it here, so feedback is appreciated. If you know of any other forums or places I should post the article before it's finished (i.e for corrections, etc.) let me know. However as I previously stated it may take a while for me to get on the net, so please don't be frustrated if I don't reply within days (or even weeks ). But I might as well be replying tomorrow or today


22 Sep 2006, 14:48 

Borsuc
Oh yes, sorry.. I am usually typing very fast and I think ahead, so I wanted to skip that "fractional part" faster with just "fraction" (sorry if this doesn't make sense). Now I realize it's wrong, thanks for the observation. I'll fix it.
My aim was to make a relatively simple but comprehensive article on fixed point, without too much math terms involved, but still explaining the math behind. Any other feedback is welcome. 

22 Sep 2006, 18:59 

Maverick
revolution wrote: A good effort overall. I got a little confused when you mentioned fractions (ie. "4/7", "1/2" etc.), but then I realised you meant the fractional component of the number (the part after the binary/decimal point). Perhaps you can reword those parts a little? I always called it "fractional part" too. By the way, do you think that the part on the left of the point should be called "integral part" or "integer part"? I'm used to call it "integral part", but I'm not 100% sure that's the correct wording. _________________ Greets, Fabio 

23 Sep 2006, 07:00 

revolution
Maverick wrote: "integral part" or "integer part"? 

23 Sep 2006, 07:33 

Maverick
That was my fear. However, in plain English, why not "Fraction part" then?
If it was my native language it would be easier. 

23 Sep 2006, 08:02 

cod3b453
The_Grey_Beast wrote: ... Thanks The_Grey_Beast 

23 Sep 2006, 21:52 

Tomasz Grysztar
A very nice explanation for "multiplication by the reciprocal", perhaps the clearest one. However, just for completeness, I'd like to note that this trick may be interpreted not only as a fixedpoint application, but also explained according to the 2adic field theory (see the discussion I once participated in on the other board). You know, the padic numbers are my research topic, that's why I'm promoting them perhaps too frequently.


23 Sep 2006, 22:20 

LocoDelAssembly
[edit] Edited last code because ADC doesn't work in that case [/edit]
[edit2] ATV has pointed me a mistake about DIV but I completely removed all the post because the article multiplies a 8.8 number so there is no need to take advantage of the 64bit produced result [/edit2] Last edited by LocoDelAssembly on 27 Sep 2006, 14:06; edited 2 times in total 

23 Sep 2006, 22:38 

vid
thanks guys, article is linked from Interesting topics now


24 Sep 2006, 09:35 

Madis731
Actually FPU is not very slow and FMUL is faster than 2 MOVs+ MUL+DIV. You didn't convince me just yet
If you think you can beat SSE+FPU with simple integer arithmetic, then I would say SSE is 4 to 8 times faster. Yeah, I see your point on making use of all the bits, but I only switch from int to float just when it isn't possible any other way. That is usually when FSINCOS and FSQRT are involved. All other algorithms can be made with ints and I think there is no middle ground. You can think of a number to be fixed point, but to me its just another int, that I'm using in some very tricky way. Btw, the multiplication and division were nice addition to my brain but until I can't use them, its just a thought floating around in my mind. Anyway, I do not feel wasting my time reading your article. It was in wellformed English and great reading. Thank you! 

25 Sep 2006, 13:29 

LocoDelAssembly
Quote: In x86 assembly this can be written a lot faster (note that I assume we have a 8.8 fractional number which cannot overflow a 32bit register; otherwise you'd have to use the "edx" register too) Sorry 

25 Sep 2006, 14:21 

ATV
locodelassembly, it shoud be "mov ecx,256" before div to move 8 bits


27 Sep 2006, 11:09 

LocoDelAssembly
Thanks, I removed the post now because it was enterely wrong anyway (because the article uses 8.8 fixed point in the example so EDX is not needed here)


27 Sep 2006, 14:08 

< Last Thread  Next Thread > 
Forum Rules:

Copyright © 19992020, Tomasz Grysztar.
Powered by rwasa.