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

Taylor Series in Verilog

I am doing my first student Project in Verilog. My project is to calculate log base 2 using "Taylor Series" in Fixed-Point arithmetic (s4.27). I have implemented the Horner's method as well in my code. Overall it looks like…
Shaown
  • 89
  • 2
  • 12
0
votes
1 answer

Is it possible to get the attributes of an sc_fix thats been passed into a function?

Fairly new to systemc, I have been reading the documentation and I know that the sc_fix type has attributes for the word length and the integer length. Is it possible to pull these attributes? I can't seem to find mention of any function that would…
Tropical_Peach
  • 1,143
  • 3
  • 16
  • 29
0
votes
3 answers

Fixed point multiply/divide for 15.16 numbers

I am looking for an algorithm to multiply and divide fixed point 15.16 numbers. I already have addition and subtraction. Those were easy - simple 32-bit add and subtract. With multiply and divide, I can also add many trigonometric and…
Thomas O
  • 6,026
  • 12
  • 42
  • 60
0
votes
1 answer

What's the math theory behind Apple's square root of fixed point algorithm

I'm working in a project where I need to calculate the square root of a 16-bit number. I'm using a NXP micro-controller that doesn't have support for float point operation. Looking online I found the following approach Fixed-Point Square Root by Ken…
0
votes
4 answers

Looking for the fastest way to divide by 2

I've searched half the day and found some very interesting things about using fixed point data types and bit shifting in C++ to accomplish division operations while avoiding floating point math. However, I have only been able to understand a small…
0
votes
1 answer

How to send a floating point number to FPGA from HPS?

I am using Altera DE0 nano SoC FPGA. I want to know how to send a floating point number to FPGA from HPS. Let a float ex_hps = 6000.9282; sent via Avalon memory mapping interface. If Avalon_write_data address has 32 bits data length (which can be…
komto909
  • 187
  • 1
  • 10
0
votes
1 answer

How to decode fixed point (VHDL) number in HPS using c language?

I am using Altera de0 nano soc FPGA. I am having number with decimal points stored in fixed point type (5 downto -27) (the number is always positive). I put it to std logic vector (32bit) and sent to HPS of soc FPGA via Avalon interface. but i do…
komto909
  • 187
  • 1
  • 10
0
votes
1 answer

Handling Overflow in Fixed Point arithmetic

I am implementing fixed point arithmetic using the slides [1]. Everything is working as it should my question is the slides linked, also every resource I read says when multiplying and dividing fixed point numbers there is a good change they…
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241
0
votes
0 answers

Working with Keras on Python: how do I switch between floating point and fixed point?

I am playing around with Keras to build neural networks. from keras.models import Sequential from keras.layers import Dense from keras.utils import np_utils import pandas as pd from sklearn.preprocessing import LabelEncoder data =…
Abhinav Goel
  • 401
  • 1
  • 6
  • 13
0
votes
2 answers

What is the range of a float represented as a Q16.16 integer?

When encoding a floating point number as a fixed point integer Q16.16 with int(number * 0x10000), what is the range of floating point that can be represented without loosing precision ?
Loic Dachary
  • 1,034
  • 1
  • 10
  • 24
0
votes
0 answers

double.ToString("F") System.FormatException in mscorelib.dll

I have C# code which converts a double with a large amount of decimal places to a string using fixed point formatting and displays it in a textbox. Here is an example: stringReadTextBox.AppendText("Test Altitude = " +T.Altitude.ToString("F") +…
Harrison
  • 57
  • 11
0
votes
1 answer

Signed Fixed Point Numbers Inequalities in Verilog

I am having problems with a verilog module in which I need to check that a fixed point number is within a set range but I am having unexpected behaviour. Here is a simplified version of what I am trying to accomplish: reg signed [4:0] signedmaxBound…
GloveTree
  • 371
  • 1
  • 6
  • 17
0
votes
2 answers

Use fractional part in fixed point calculation

I have a calculation which is the following: 1472 / 48 = 30.666667 (30 * 48) = 1440 (0.666667 * 48) = 32 So the numbers I nead are 1440 and 32, which can be calculated with the real part and the fractional part of the first calculation. Using the…
boortmans
  • 1,138
  • 2
  • 24
  • 40
0
votes
1 answer

Determinisitic Compute Shader For Simplex Noise In Unity

So I have been trying to use the power of compute shaders to speed up the process of generating simplex noise for my map terrain generation in unity. The problem is that for the game to work it requires everything to be deterministic in order to…
0
votes
2 answers

Fixed point aritmetic in MIPS

I need to implement some code in MIPS assembly, in particular using fixed point arithmetic. Did I miss something or there is no such thing there? If its not part of MIPS, how can I implement fixed point using integers, that is add/sub/mul/div?
ArekBulski
  • 4,520
  • 4
  • 39
  • 61