Questions tagged [fixed-point]

Questions about fixed-point arithmetic, done using a set number of decimal places. For the combinators used to encode recursion, use [fixpoint-combinators] instead. For the numerical method, use [fixed-point-iteration] instead. For the fixedpoint engine of Z3, use [z3-fixedpoint] instead.

Fixed point arithmetic uses a fixed radix position to do calculations, instead of a variable amount (floating point). Instead of representing numbers using the IEEE mantissa-and-exponent format, numbers are represented as integers which are scaled by a fixed amount. It can be faster and is, within its regime, more precise than floating-point.

Most questions deal with finding a suitable fixed-point library for [insert language here], as most languages lack fixed-point arithmetic in their standard libraries (although some have one natively). Also, different types of fixed point number exist based on the number of decimal points included (and thus accuracy) - see the Q format.

511 questions
0
votes
1 answer

float to fixed conversion with different scaling factors

Can anyone please let me know What will be the difference between these approcahes when I convert fixed to float and float to fixed. a) int a=32767; float b = 32765*(1/32767) // 16 bit scaling factor int c = b*32767; b) int a=32767; float b =…
Viks
  • 760
  • 4
  • 12
  • 26
0
votes
1 answer

Fixed Point Multiplication for FFT

I’m writing a Radix-2 DIT FFT algorithm in VHDL, which requires some fractional multiplication of input data by Twiddle Factor (TF). I use Fixed Point arithmetic’s to achieve that, with every word being 16 bit long, where 1 bit is a sign bit and the…
refDL
  • 89
  • 3
  • 11
0
votes
1 answer

Hardware for "A div B" with A and B fixed point

I need a way to compute how many times a fixed point number B is contained into a fixed point number A. Something like integer division but on non-integer operands. I need to design an hardware block for this operation. My first guess is to use…
KBowser
  • 31
  • 3
0
votes
1 answer

Fixed and floating point in Verilog

I come from VHDL back ground. And in VHDL, there is IEEE packages for doing fixed and floating point operations. They are not synthesisable sometimes, but are pretty helpful when comes to testing. My question is, whether Verilog has a library for…
vipin
  • 1,610
  • 3
  • 16
  • 27
0
votes
2 answers

converting float to fixed point in python

I think I am overthinking this probelem, but I can't seem to solve it. I am reading in little endian floats from a file (range (-1,1)), and want to convert them to fixed point 32b. If I read in the value 0xA0C1943B, that equates to a float of…
toozie21
  • 341
  • 2
  • 6
  • 15
0
votes
0 answers

Haskell Data.Fixed.Binary status

There is a package in Hackage called Data.Fixed.Binary that I am interested in. The problem I have is that it appears not to work with recent releases of base. I would like to know if there is a reason against having a this package. Did I miss a…
0
votes
1 answer

fixed point multiplication for normal multiplication

I need to multiply X with a floating point number in floating point as i don't have floating point operations in my processor. I understand the method but don't know why that method exists? Suppose we want to multiply 2*4.5 in decimal I do the…
newbie_old
  • 500
  • 5
  • 19
0
votes
1 answer

fixed point subtraction for two's complement data

I have some real data. For example +2 and -3. These data are represented in two's complement fixed point with 4 bit binary value where MSB represents the sign bit and number of fractional bit is zero. So +2 = 0010 -3 = 1101 addition of this two…
Sourav
  • 1
0
votes
2 answers

Fixed point code division understanding

Code for division by 9 in fixed point. 1. q = 0; // quotient 2. y = (x << 3) - x; // y = x * 7 3. while(y) { // until nothing significant 4. q += y; // add (effectively) binary 0.000111 5. y >>= 6; …
newbie_old
  • 500
  • 5
  • 19
0
votes
3 answers

16-bit fixed point arithmetic multiplication

I have 2 data values (A = 0.00537667139546100 and B = -0.0182905843325460) and I want to multiply them using 16-bit fixed point arithmetic by using round off method. How should I do that? How should I define the both data? Is it reg or signed? Is…
Jack93
  • 21
  • 1
  • 4
  • 13
0
votes
1 answer

Multiplication of 32 bits numbers in C

Why the below code produces this error? error: left shift count >= width of type [-Werror] The code: int32_t a,b; int64_t apo; a = 2673; b = 19; apo = BIG_MULL(a,b); printf("\n %ld \n", apo ); The macros found here: #define WORD_MASK ((1<<16) -…
Franx
  • 87
  • 1
  • 10
0
votes
2 answers

How to fix the position of binary point in an unsigned N-bit interger?

I am working on developing a fixed point algorithm in C++. I know that, for a N-bit integer, the fixed point binary integer is represented as U(a,b). For example, for an 8 bit Integer (i.e 256 samples), If we represent it in the form U(6,2), it…
PsychedGuy
  • 187
  • 3
  • 11
0
votes
2 answers

Determine binary digits

I have a number of coefficients of type double, which should be stored on an FPGA as signed 16-bit numbers. For that I need to configure how many bits of the 16bit should be used for the fraction and how many for the integer part. So the idea is,…
Daiz
  • 357
  • 1
  • 3
  • 20
0
votes
2 answers

Float to fixed conversion

This is a basic question but I am confused. I have a register which has the format 1.4.12. Meaning it takes a float and takes the range -15.9999 - 15.9999, is that correct, or how many nines? I am confused by the range. I need to convert a c++…
user1876942
  • 1,411
  • 2
  • 20
  • 32
0
votes
1 answer

subtracting numbers in fixed point format

I have two numbers in fixed point a(Q2n1,2m1) and b(Qn1,m1). to subtract these numbers a should have the same exponent size of b. now how to subtract them. I tried shifting a by m1 times to the right then a becomes (Q2n1,m1), but won't it affect the…
phanitej
  • 113
  • 5