Board index » delphi » Integer to Float function needed
d.a.schwei...@idontwantspam.gamma.rug.nl (David A. Schweizer)
Delphi Developer |
Sun, 13 Feb 2000 03:00:00 GMT
Integer to Float function neededOn Wed, 27 Aug 1997 01:05:14 GMT, David Irizarry Quote<xerx...@ix.netcom.com> wrote: automatically convert integers into reals when necessary, i.e. 1) when assigned to a real variable, explicitly (x := i) or implicitly (as parameters to a function or procedure) 2) when part of a real type expression The only situation I can come up with where you need to do a int-float nrSeconds := 3600 * hr + 60 * min + sec where hr is an integer variable, and nrSeconds a real. This might cause integer overflow if hr is larger than 8, because all The solution in this case, as in most cases, is forcing the expression nrSeconds := 3600.0 * hr + 60 * min + sec Sometimes you might have to do this explicitly. In that case you can x := i1 + i2 where i1 and i2 are integers containing large values, so when added x := 1.0 * i1 + i2 (which might not even waste any clock cycles) hth ------------------ iec ProGAMMA, The Netherlands |