![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#4
|
||||
|
||||
|
yo tengo una rutina para redondear las cantidades float a dos decimales porque tengo el mismo problema. antes de guardar datos la aplico y solucionado el problema
![]() no recuerdo el nombre del autor, pero sigo agradeciendole esta rutina fCostoult:=RoundN((grdMov.Floats[7,i]/grdMov.Floats[4,i]),2) d es el numero de decimales que vas a querer function TFCapfac.RoundN(x: Extended; d: Integer): Extended; // RoundN(123.456, 0) = 123.00 // RoundN(123.456, 2) = 123.46 // RoundN(123456, -3) = 123000 const t: array [0..12] of int64 = (1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000); begin if Abs(d) > 12 then raise ERangeError.Create('RoundN: Value must be in -12..12'); if d = 0 then Result := Int(x) + Int(Frac(x) * 2) else if d > 0 then begin x := x * t[d]; Result := (Int(x) + Int(Frac(x) * 2)) / t[d]; end else begin // d < 0 x := x / t[-d]; Result := (Int(x) + Int(Frac(x) * 2)) * t[-d]; end; end; |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
|