## Reference.Float History

June 03, 2010, at 12:47 AM by Equipo Traduccion -
June 03, 2010, at 12:47 AM by Equipo Traduccion -
Changed lines 3-5 from:

#### Description

Datatype for floating-point numbers, a number that has a decimal point. Floating-point numbers are often used to approximate analog and continuous values because they have greater resolution than integers. Floating-point numbers can be as large as 3.4028235E+38 and as low as -3.4028235E+38. They are stored as 32 bits (4 bytes) of information.

to:

#### Descripcion

El tipo variable para los números en coma flotante (número decimal). Estos números son usados, habitualmente, para aproximar valores analógicos y contínuos, debido a que ofrecen una mayor resolución que los enteros. Las variables tipo float tienen el valor máximo 3.4028235E+38, y como mínimo pueden alacanzar el -3.4028235E+38. Ocupan 4bytes (32bits).

Changed lines 8-15 from:

Floats have only 6-7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point. Unlike other platforms, where you can get more precision by using a double (e.g. up to 15 digits), on the Arduino, double is the same size as float.

Floating point numbers are not exact, and may yield strange results when compared. For example `6.0 / 3.0` may not equal `2.0`. You should instead check that the absolute value of the difference between the numbers is less than some small number.

Floating point math is also much slower than integer math in performing calculations, so should be avoided if, for example, a loop has to run at top speed for a critical timing function. Programmers often go to some lengths to convert floating point calculations to integer math to increase speed.

#### Examples

to:

Los floats tienen una precisión de 6 o 7 dígitos decimales. Esto significa el número total de dígitos, no el número a la derecha de la coma decimal. Al contrario que en otras plataformas, donde tu podrías obtener mayor precisión usando una variable tipo double (por ejemplo, por encima de 15 dígitos), en Arduino los double tienen el mismo tamaño que los float.

Los números en coma flotante no son exactos, y muchos proporcionan falsos resultados cuando son comparados. Por ejemplo, `6.0 / 3.0` puede no ser igual a `2.0`. Debes comprobar que el valor absoluto de la diferencia entre los números pertenezca a un rango pequeño.

La matemática en coma flotante es mucho más lenta que la matemática de enteros para realizar operaciones, por lo que deberías evitarla si, por ejemplo, un bucle tiene que ejecutarse a la máxima velocidad para funciones con temporizaciones precisas. Los programadores normalmente suelen asignar unas longitudes para convertir las operaciones de coma flotante en cálculos con enteros, para aumentar la velocidad.

#### Ejemplos

Changed lines 19-20 from:

to:

#### Sintaxis

Changed lines 23-26 from:
• var - your float variable name
• val - the value you assign to that variable

#### Example Code

to:
• var - el nombre de la variable tipo float
• val - el valor que le asignas a esa variable

#### Código de ejemplo

Changed lines 33-40 from:
```   y = x / 2;            // y now contains 0, ints can't hold fractions
z = (float)x / 2.0;   // z now contains .5 (you have to use 2.0, not 2)@]
```

to:
```   y = x / 2;            // y ahora contiene 0, la parte entera de la operación
z = (float)x / 2.0;   // z ahora contiene 0.5 (se debe usar 2.0, en lugar de 2)
```

@]

#### Ver también

Changed line 42 from:
• Variable Declaration
to:
March 31, 2010, at 06:17 PM by David A. Mellis -
Changed lines 7-8 from:

Floats have only 6-7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point. On most platforms you can get more precision by using a double. But even those have limited precision, typically 15 digits. But, on the arduino, doubles are the same size as floats.

to:

Floats have only 6-7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point. Unlike other platforms, where you can get more precision by using a double (e.g. up to 15 digits), on the Arduino, double is the same size as float.

March 29, 2010, at 09:18 PM by Tom Igoe -
Changed lines 6-8 from:
to:

Floats have only 6-7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point. On most platforms you can get more precision by using a double. But even those have limited precision, typically 15 digits. But, on the arduino, doubles are the same size as floats.

June 25, 2009, at 01:05 PM by Paul Badger -
• Variable Declaration
May 13, 2009, at 06:37 AM by Paul Badger -

May 13, 2009, at 06:34 AM by Paul Badger -
Changed lines 33-36 from:

#### Programming Tip

Serial.println() truncates floats (throws away the fractions) into integers when sending serial. Multiply by power of ten to preserve resolution.

to:

November 02, 2008, at 11:32 AM by David A. Mellis -
Deleted lines 10-12:

That being said, floating point math is useful for a wide range of physical computing tasks, and is one of the things missing from many beginning microcontroller systems.

May 29, 2007, at 05:24 AM by David A. Mellis -
Changed lines 7-8 from:

Floating point math is much slower than integer math in performing calculations, so should be avoided if, for example, a loop has to run at top speed for a critical timing function. Programmers often go to some lengths to convert floating point calculations to integer math to increase speed.

to:

Floating point numbers are not exact, and may yield strange results when compared. For example `6.0 / 3.0` may not equal `2.0`. You should instead check that the absolute value of the difference between the numbers is less than some small number.

Floating point math is also much slower than integer math in performing calculations, so should be avoided if, for example, a loop has to run at top speed for a critical timing function. Programmers often go to some lengths to convert floating point calculations to integer math to increase speed.

May 29, 2007, at 03:08 AM by Paul Badger -
Changed line 31 from:
```   y = x / 2;   // y now contains 0, integers can't hold fractions
```
to:
```   y = x / 2;            // y now contains 0, ints can't hold fractions
```
April 17, 2007, at 12:05 AM by David A. Mellis -
Changed lines 17-18 from:

to:

#### Syntax

April 16, 2007, at 06:38 PM by Paul Badger -
Changed lines 26-33 from:

int x; int y; float z;

x = 1; y = x / 2; // y now contains 0, integers can't hold fractions z = (float)x / 2.0; // z now contains .5 (you have to use 2.0, not 2)@]

to:
```   int x;
int y;
float z;
```

```   x = 1;
y = x / 2;   // y now contains 0, integers can't hold fractions
z = (float)x / 2.0;   // z now contains .5 (you have to use 2.0, not 2)@]
```
April 16, 2007, at 06:36 PM by Paul Badger -
Deleted line 37:
April 14, 2007, at 10:14 PM by Paul Badger -
Changed lines 32-33 from:

z = x / 2.0; // z now contains .5 (you have to use 2.0, not 2)@]

to:

z = (float)x / 2.0; // z now contains .5 (you have to use 2.0, not 2)@]

April 14, 2007, at 06:01 PM by David A. Mellis - correcting float = int / int; to float = int / float;
Changed lines 32-33 from:

z = x / 2; // z now contains .5@]

to:

z = x / 2.0; // z now contains .5 (you have to use 2.0, not 2)@]

April 14, 2007, at 07:06 AM by Paul Badger -
Changed line 9 from:

That being said, floating point math is one of the things missing from many beginning microcontroller systems.

to:

That being said, floating point math is useful for a wide range of physical computing tasks, and is one of the things missing from many beginning microcontroller systems.

Changed lines 22-24 from:
• val - the value you assign to that variable

to:
• val - the value you assign to that variable

#### Example Code

```int x;
int y;
float z;

x = 1;
y = x / 2;   // y now contains 0, integers can't hold fractions
z = x / 2;   // z now contains .5
```

#### Programming Tip

Serial.println() truncates floats (throws away the fractions) into integers when sending serial. Multiply by power of ten to preserve resolution.

April 14, 2007, at 06:54 AM by Paul Badger -
Changed lines 14-15 from:
``` float myfloat;
```

float sensorCalbrate = 1.117;

to:
```    float myfloat;
float sensorCalbrate = 1.117;
```
April 14, 2007, at 06:51 AM by Paul Badger -
Changed lines 7-9 from:

Floats are much slower than integers to perform calculations with, so should be avoided if, for example, a loop has to run at top speed for a critical timing function.

to:

Floating point math is much slower than integer math in performing calculations, so should be avoided if, for example, a loop has to run at top speed for a critical timing function. Programmers often go to some lengths to convert floating point calculations to integer math to increase speed.

That being said, floating point math is one of the things missing from many beginning microcontroller systems.

Changed lines 18-20 from:
```    int var = val;
```

• var - your int variable name
to:
```    float var = val;
```

• var - your float variable name
Deleted lines 23-26:

April 14, 2007, at 06:43 AM by Paul Badger -

## float

#### Description

Datatype for floating-point numbers, a number that has a decimal point. Floating-point numbers are often used to approximate analog and continuous values because they have greater resolution than integers. Floating-point numbers can be as large as 3.4028235E+38 and as low as -3.4028235E+38. They are stored as 32 bits (4 bytes) of information.

Floats are much slower than integers to perform calculations with, so should be avoided if, for example, a loop has to run at top speed for a critical timing function.

#### Examples

``` float myfloat;
```

float sensorCalbrate = 1.117;

#### Parameters

```    int var = val;
```

• var - your int variable name
• val - the value you assign to that variable