Date: Mon, 22 Jul 1996 07:45:31 +0200 (IST) From: Eli Zaretskii To: David L Clayton Cc: "'DJGPP mail place'" Subject: Re: Float to integer conversion In-Reply-To: <01BB774E.D15FEDE0@gw2-134.pool.dircon.co.uk> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 21 Jul 1996, David L Clayton wrote: > Could somebody please tell me the best way to change an integer number > to a float, and vice versa? Int to float is easy: int i; double f = i; or, if you need it in an expression: f = (double)i; However, to convert double (or float) into an int, you usually want to round it to the nearest integer: int i = f + 0.5;