www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/21/19:31:11

Xref: news2.mv.net comp.os.msdos.djgpp:6231
From: jlouwere AT galaxy DOT csc DOT calpoly DOT edu (Jan Louwerens)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Float to integer conversion
Date: 21 Jul 1996 22:43:47 GMT
Organization: Cal Poly Computer Science Dept.
Lines: 17
Message-ID: <4subr3$74s@waldorf.csc.calpoly.edu>
References: <01BB774E DOT D15FEDE0 AT gw2-134 DOT pool DOT dircon DOT co DOT uk>
NNTP-Posting-User: jlouwere AT galaxy DOT csc DOT calpoly DOT edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

David L Clayton (dclayton AT dircon DOT co DOT uk) wrote:
: Could somebody please tell me the best way to change an integer number to a
: float, and vice versa?

just type cast it.

int i = 4;
float f = 6.0;

float to int:
i = (int)f;

int to float:
f = (float)i;

JL

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019