Meaning of FXP "Word Length" vs "Integer Word Length"fixed point maths
Posted 14 March 2012 - 10:42 PM
Tinkering with my FPGA code today, I ran into a question which I'd never really contemplated before. Say I have an unsigned FXP number with word length = 1 and integer word length = 2. Labview tells me that this gives a maximum of 2 with a delta of 2, so the number can either be 0 or 2.
This makes no intuitive sense to me, the way I understood it, the word length is the total number of bits used to capture the number, the integer word length is the number of bits dedicated to capturing the integer portion, in other words, it kind of defines the "magnitude" of the number that can be captured, the remaining bits are used to give the "precision" to which the number is captured. So how is it even possible for the "integer word length" to be greater than the "word length"?
Insight much appreciated.
Posted 14 March 2012 - 11:48 PM
Edited by ned, 14 March 2012 - 11:49 PM.
- asbo likes this
Posted 01 June 2013 - 04:32 PM
The example that I keep tucked in the ol' noodle is the exceedingly bizarre situation of a FXP number with a WL of 1 and an IWL of -1024, meaning you have 1 bit to represent the value (so only two numbers in the range) and that they are the exceedingly small numbers around 0, so ±2^-1024
-Attributed to Samuel Clemens
Posted 03 June 2013 - 01:49 PM
If you are ever unsure of the range a number holds I just test it. Put in a few numbers into both controls and then try to end numbers into the control to see the range and resolution. I agree that the controls aren't labeled in an intuitive way but I can always test it to make sure it is working right.
"Maybe Hoovah is really Crelf's alter-ego, which he uses to irk people?" - Gary Rubin
"Seemingly minor changes....can mean the difference between a working app and a quivering heap of unresponsive code." - David Boyd
"Using unofficial features of LabVIEW is cat nip laced with poison."
Posted 03 June 2013 - 03:22 PM
You could also look at it as the position where the decimal point is set. If you have (word length == integer length) then you have the decimal point just after the last bit so this comes out as a normal integer. With your settings you get a single flip-flop which is interpreted as bit 1 of an integer, therefore you get the two values 0 = 0*2^1 and 2 = 1*2^1.
Waiting for the responding edition ...