# How to speed up

I found that using more float variable in arduino uno(atmega328p) slows it down (very muck that i can get slow response)

so, how to speed up it processing ?

my data are euler's angle with 2 digits and 2 decimals like give below

XX.XX , where X is number Eg.(85.63,34.65,etc) (from MPU6050)

How to process it fast?

• Add the code for the slow procedure (or add your whole program) into the question. Details make differences. To tell markdown that a section is `code`, highlight it and press ctrl-K – James Waldby - jwpat7 Feb 25 '16 at 17:56
• i just found by multiplying raw value by 100 (85.63 * 100 = 8563),it is still integer so it will be fast in arduino uno. And divide it by 100 to get processed value – user3805290 Feb 25 '16 at 18:02

## 1 Answer

A technique commonly used in digital signal processing is using fixed-point arithmetic instead of floating point. In fixed-point arithmetic, one calculates using numbers multiplied by some power of two or ten, and in effect mentally positions a binary or decimal point several bits or digits up while calculating. Numerical analysis may be needed to determine if the arithmetic is accurate enough and whether numbers will stay in bounds, or overflow.

The question doesn't say what's being calculated; it's possible fixed-point arithmetic might work, or might not. A short self-contained fixed-point calculation that starts with MPU6050 sensor readings is likely to be ok, but long-term calculations (eg, integration of accelerations to get velocities and positions) that let error accumulate without reset may go too far astray. In such a case, numerical analysis can indicate what intermediate results need to be stored most accurately.

Typically, when slow code is posted someone can point out speedups, from a few percent up to dozens of times faster. Changes may range from adding or removing parentheses or temporary variables, to refactoring, to substitution of a new algorithm.

• yeah i am now modifying code . – user3805290 Feb 25 '16 at 18:10