PASCAL CON FREE PASCAL
PASCAL CON FREE PASCAL
PASCAL CON FREE PASCAL
|
3. OPERADORES PARA TIPOS DE DATOS SIMPLES. 3.9. FUNCIONES TRUNC - INT - FRAC.
3. OPERADORES PARA TIPOS DE DATOS SIMPLES. 3.9. FUNCIONES TRUNC - INT - FRAC.
3. OPERADORES PARA TIPOS DE DATOS SIMPLES. 3.9. FUNCIONES TRUNC - INT - FRAC.
|
|
SIGUIENTE
SIGUIENTE
SIGUIENTE
|
‒ Funciones Trunc - Int - Frac.
La función trunc, nos permite obtener la parte entera de un número real, devolviéndonos como resultado un dato de tipo int64, la función Int, hace lo mismo que la función trunc, con la diferencia que devuelve un dato de tipo real. La función Frac, nos permite obtener la parte fraccionaria de un número real, devolviéndonos como resultado un dato de tipo real. Ejemplo:
‒
Descargar
{$codepage UTF8}
VAR
Num1:single;
ParteEnt,ParteFrac:single;
Ent:integer;
BEGIN
Num1:=65.89;
//Ejemplo Trunc
Ent:=Trunc(Num1);
Writeln(Ent);
//Ejemplo Int
ParteEnt:=Int(Num1);
Writeln(ParteEnt:5:2);
//Ejemplo Frac
ParteFrac:=Frac(Num1);
Writeln(ParteFrac:5:2);
Readln()
END.
Código fuente 15: Ejemplo del uso de las función int, trunc y frac.
Descargar
‒ Comentarios y sugerencias.