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
4 answers

Custom binary representation of fixed point number

Is there a way to obtain the binary representation of a number in Python? It has to be able to represent negative numbers as well. I already tried the function from numpy np.binary_repr(Decimal(-1)) but it results in an error. To be precise - I want…
Adrian Jałoszewski
  • 1,695
  • 3
  • 17
  • 33
0
votes
1 answer

Fixed-point: out_Q15 = antilog( in_Q25 ) calculation, avoiding overflow?

I am using a 3rd-party fixed-point antilog() function to calculate magnitude from decibel out_mag = 10^( in_db/20 ). The antilog() takes Q6.25 format as input, and provides Q16.15 at output. The problem is that antilog() quickly overflows for some…
Danijel
  • 8,198
  • 18
  • 69
  • 133
0
votes
1 answer

Fixed point implementation of Kalman filter behaving strangely

I have implemented several implementations of a linear Kalman filter tracking a sine wave. I have a Python and a C implementation that both work. However I have also developed a version that uses a fixed point implementation and it works, but I am…
SomeRandomPhysicist
  • 1,531
  • 4
  • 19
  • 42
0
votes
1 answer

How to perform division of two Q15 values in Verilog , with out using '/' (division) Operator?

As division operation (/) is expensive in case of FPGA ? Is it possible to perform division of two Q15 format numbers(16 bit fixed point number) with basic shift operations? Could someone help me by providing some example? Thanks in advance!
0
votes
1 answer

Trigonometry/Floating point issue

The issue: When using the math.h trigonometry functions with a simple SDL 2.0.4 application (top-down movement/rotation attempt), I discovered that there were some slight errors in the trigonometry calculations, resulting in the 'player' not moving…
T. Lane
  • 13
  • 3
0
votes
1 answer

Looking for good scale factor for converting log to 8.8 fixed point

I have a range of numbers in (0, 1] I would like to take the natural log of these numbers, and then store as 8.8 fixed point. My foruma is K*ln(x) + (1<<16) but I am not sure what the best value is for K . My thinking is that if x doubles, then…
Jacko
  • 12,665
  • 18
  • 75
  • 126
0
votes
1 answer

what is the most negative fraction that can be represented by a n bit binary number in 2's complement?

I am reading computer architecture by Carl Hamacher. The following lines are confusing me If we use a 32-bit binary number to represent a signed integer in 2's complement then the range of values that can be represented is -2^31 to 2^31 - 1.…
Kishan Kumar
  • 685
  • 1
  • 5
  • 17
0
votes
3 answers

Simple low pass filter in fixed point

I have a simple circuit setup to read the light level via an LDR into an Arduino. I'm trying to implement a simple low pass filter to data read in. How best to tackle this given that analogRead() returns an unsigned int. I have tried to implement a…
CatsLoveJazz
  • 829
  • 1
  • 16
  • 35
0
votes
1 answer

how to generate fixed point code from a continuous block model?

I am trying to generate C code for controller and plant models which are continuous in time, so the code shall be generated with floating point support. But the my real-time target (RTlinux kernel x86) does not support floating point processes. So,…
0
votes
0 answers

How to convert powers of 2 number to multiples of 10 number?

I would like to create a function which converts powers of 2 to multiples of 10. can anybody help in providing algorithm such that function should use only integers .. Should not use ang float variable. FUN_Convert(100,524247,1024)…
0
votes
1 answer

how to out fixed point value in verilog?

I'm trying to out the fixed point value in verilog. Generally, I use like this method (I'don't know what it was called) for example, output = 0.248*5 output = ((0.248 << 8) * 5 ) >> 8; But in his case the output has only integer. I want to get…
nashile
  • 23
  • 2
  • 6
0
votes
0 answers

Matlab Simulink Discrete-Time Integrator Block with fixed point data type

I designed a controller in Simulink, which I want to compile in HDL and flash to an FPGA. Therefore I have to define the used data types in fixed point style rather than the standard double that Simulink chooses. Every block I am using is working…
Jonnnny
  • 95
  • 1
  • 2
  • 6
0
votes
1 answer

Unsigned fixed point rationals

Why unsigned fixed point rational has the range 2^a - 2^-b? Where a represents integer bits, and b represents fractional bits of the given number. How I can determine the max value, unsigned fixed point rational can give?
user5585984
0
votes
1 answer

Convert signed fixed point to float

I have got number in this mode: Value mode = 16-bit fixed point (signed) And how I can convert this number to floating point? Any idea? Can I use this function, when this number is signed? float toFloat(int16_t val) { return…
Jirka
  • 63
  • 1
  • 15
0
votes
1 answer

Verilog display reg value based on fraction length

Say you have a signed 32bit number with a fraction length of 16bits. That is, the first 16 MSB are the integer part and the rest ( 16 LSB) are the fraction part. Is there a way in verilog to display this number number in base 10 that makes it easier…
user3697625
  • 167
  • 4
  • 17