float()

De ArduWiki
Revisión del 20:45 18 jul 2019 de Kike GL (Discusión | contribuciones) (Parametros)

Saltar a: navegación, buscar

Descripción

Convierte un valor numérico de cualquier tipo a float.

Sintaxis

float(variable);

Parametros

variable
variable de cualquier tipo a evaluar. char, byte, int, long, double.

Retorna

Retorna un numero tipo float.

Advertencias

No funciona con cadenas string ni objetos String.

Ejemplo

char a = 'A';
byte b = 123;
int c = -123.45;

void setup(){
   Serial.begin(9600);

   byte valor1 = byte(a);
   Serial.println(valor1);

   int valor2 = long(b);
   Serial.println(valor2);

   unsigned int valor3 = word(b);
   Serial.println(valor3);

   long valor4 = long(b);
   Serial.println(valor4); 

   float valor5 = float(c);
   Serial.println(valor5); 
}
 
void loop(){
   //Nada.
}

Vea también


Referencias externas