Organize and Share your Electronics the way you want. Sign-Up for a free account now. It takes only 30 seconds!

The Art of Representing Floating-Point Numbers as Integers

The Art of Representing Floating-Point Numbers as Integers

Mário Ribeiro writes:

Have you been using float or double variables to perform mathematical operations on embedded systems without a Floating-Point Unit (FPU)? You are doing it wrong! That’s incredibly inefficient.

An FPU is an hardware block specially designed to carry on arithmetic operations on floating point numbers. Even though the C/C++ code may work without an FPU, it’s always much faster to use hardware designed for a specific purpose, like this one, instead of relying on a software implementation, something that the compiler will do for you, knowing the hardware restrictions you have but not in an efficient manner. Essentially, it will generate a lot of assembly code, greatly increasing the size of your program and the amount of time required to complete the operation. Thus, if you don’t have an FPU available and you still want to perform those arithmetic operations efficiently you’ll have to convert those numbers to fixed-point representation. Integers! But how? By scaling them. Let’s see how that scaling value may be determined.

The Art of Representing Floating-Point Numbers as Integers – [Link]

 

More Articles to Read

Bookcase automatically opens to reveal secret lair
Bookcase automatically opens to reveal secret lair
PCI Express High Performance Reference Design
PCI Express High Performance Reference Design
Muxtronics open source 12V powerbank
Muxtronics open source 12V powerbank
TI’s Little Professor
TI’s Little Professor
App note: Testing inductors at application frequencies
App note: Testing inductors at application frequencies
1968 Princeton Reverb Repairs
1968 Princeton Reverb Repairs
Skill Sunday: Power Over Ethernet for Arduino
Skill Sunday: Power Over Ethernet for Arduino
More on Color TFT Displays ~ The Big Ones — 240 X 320
More on Color TFT Displays ~ The Big Ones — 240 X 320
Magnetic Rotary Encoder
Magnetic Rotary Encoder
Vertical Pole Climbing Robot
Vertical Pole Climbing Robot

Top




Shares