fixed-point

Is it better to use GL_FIXED or GL_FLOAT on Android.

I would have assumed that GL_FIXED was faster, but the iPhone docs actually say to use GL_FLOAT because GL_FIXED has to be converted to GL_FLOAT. Is it the same on Android? I suppose it varies by phone, but what about recent popular ones (Nexus One, Droid/Milestone, etc.)? Bonus points: This appears to be completely undocumented (e.g. s...

Fixed point multiplication "solution," crazy or viable?

Assume this much: I'm using a 16.16 fixed point system. System is 32 bit. CPU has no floating point processor. Overflow is pretty imminent for multiplication for anything larger than 1.0 * 0.4999 To make one last assumption... lets say the values I'm working will not be so high as to cause overflow in this operation... //assume that in...

C++ fixed point library?

I am looking for a free C++ fixed point library (Mainly for use with embedded devices, not for arbitrary precision math). Basically, the requirements are: No unnecessary runtime overhead: whatever can be done at compile time, should be done at compile time. Ability to transparently switch code between fixed and floating point, with no ...

U combinator on a fibonacci : how would you translate this code to python?

Hi, I am trying to learn about combinators and I am having trouble understand the example given at (Y overriding self-application). I think I am beginning to grasp the concept but I am still far from understanding. I would like to translate the following code to Python: (define (U f) (f f)) (define (fib-nr f) (lambda...

Arm assembler right shifting after multiplpy long ?

Newbie ARM assembler question. I am writing my first arm assembler program and I am trying to code this C fragment. int x = somevalue1 << 12; // s19.12 int y = somevalue2 << 12; // s19.12 int a = somevalue3 << 12; // s19.12 int b = somevalue4 << 12; // s19.12 int c = somevalue4 << 12; // s19.12 long long acc = (long long) a * b;...

Floating Point Algorithms in C

Hi, I am thinking recently on how floating point math works on computers and is hard for me understand all the tecnicals details behind the formulas. I would need to understand the basics of addition, subtraction, multiplication, division and remainder. With these I will be able to make trig functions and formulas. I can guess something...

Fixed point combinators for functions over custom types?

Most examples of the use of fixed point combinators involve functions that take integers to integers (e.g. factorial). In many cases the fixed point of a function over the real numbers will end up being an arbitrary rational or perhaps irrational number (a famous example is the logistic map http://en.wikipedia.org/wiki/Logistic_map). In ...

Fixed point combinator usage? Why a stack overflow here?

I am confused about something. I wanted to generate an example (in Clojure) demonstrating how a fixed point combinator could be used to evaluate the fixed point of a sequence that mathematically converges after an infinite number of applications but would, in fact, converge after a finite number of steps due to finite precision of floati...

Fixed-point multiplication in a known range

Hi, I'm trying to multiply A*B in 16-bit fixed point, while keeping as much accuracy as possible. A is 16-bit in unsigned integer range, B is divided by 1000 and always between 0.001 and 9.999. It's been a while since I dealt with problems like that, so: I know I can just do A*B/1000 after moving to 32-bit variables, then strip back to...

float to fixed conversion with different scaling factors.

Hi 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 = 32765*(1/1.0) // scaling factor=1 int c = b*1; a) int a=32767; float b = 32765*(1/0x800...

How can I perform 64-bit division with a 32-bit divide instruction?

This is (AFAIK) a specific question within this general topic. Here's the situation: I have an embedded system (a video game console) based on a 32-bit RISC microcontroller (a variant of NEC's V810). I want to write a fixed-point math library. I read this article, but the accompanying source code is written in 386 assembly, so it's nei...

Python: create fixed point decimal from two 32-bit ints (one for int portion, one for decimal)

I have a 64-bit timestamp unpacked from a file with binary data, where the top 32 bits are the number of seconds and the bottom 32 bits are the fraction of the second. I'm stuck with how to actually convert the bottom 32 bits into a fraction without looping through it bit-by-bit. Any suggestions? For reference, the number 4ca1f350 948...

Convert a double to fixed decimal point in C++

I have a double variable in C++ and want to print it out to the screen as a fixed decimal point number. Basically I want to know how to write a function that takes a double and a number of decimal places and prints out the number to that number of decimal places, zero padding if necessary. For example: convert(1.235, 2) would print ...

Conversion of fixed point signed Q8 to Q4 format

Hi I need to convert from fixed point signed Q8 format to fixed point signed Q4 format in c. I assume that I can just do a bitshift by four, is this correct? Do I need to take into account the sign bit? Update: This is for an ARM11 architecture, but I would prefer a non-architecture specific solution. Thanks ...

How to treat a struct with two unsigned shorts as if it were an unsigned int? (in C)

I created a structure to represent a fixed-point positive number. I want the numbers in both sides of the decimal point to consist 2 bytes. typedef struct Fixed_t { unsigned short floor; //left side of the decimal point unsigned short fraction; //right side of the decimal point } Fixed; Now I want to add two fixed point number...