delorie.com/archives/browse.cgi | search |
Date: | Mon, 22 Jul 1996 07:45:31 +0200 (IST) |
From: | Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> |
To: | David L Clayton <dclayton AT dircon DOT co DOT uk> |
Cc: | "'DJGPP mail place'" <djgpp AT delorie DOT com> |
Subject: | Re: Float to integer conversion |
In-Reply-To: | <01BB774E.D15FEDE0@gw2-134.pool.dircon.co.uk> |
Message-Id: | <Pine.SUN.3.91.960722074147.7625A-100000@is> |
Mime-Version: | 1.0 |
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;
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |