Re:Typecasting
On Thu, 16 Oct 1997 21:30:37 +0100, "Sean Radford"
Quote
<s...@bladesys.demon.co.uk> wrote:
>How do I typecast an integer into a real number, and visa-verse. I don't
>seem to be able to!
>Sean Radford
If you try to do "Integer(MyReal)" or "Real(MyInt)", it won't work as
expected, even if you happened to get the code compile (when
typecasting, types must be of equal size). Instead, you should do:
MyInt := Trunc(MyReal);
or
MyInt := Round(MyReal);
and
MyReal := MyInt*1.0;
HTH.
Regards,
Jani J?rvinen
Helsinki Finland
Tools, information, tips, reviews & bug lists
for professional Delphi, Win32 and WinHelp developers.
mailto:ja...@dystopia.fi
http://www.dystopia.fi/~janij/