delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/27/19:39:23

From: Charles Krug <charles AT mail DOT pentek DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [DESPERATE newbie]How to round a float to an int?
Date: Wed, 27 Jan 1999 17:41:59 -0500
Organization: Pentek Corporation
Lines: 31
Message-ID: <36AF9637.EAB66C9E@mail.pentek.com>
References: <78nicq$ph6$1 AT zingo DOT tninet DOT se>
NNTP-Posting-Host: mail.pentek.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.5 [en] (WinNT; U)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Benny börjesson" wrote:

> Is there a function to round a float to an int(in c++)included in the DJGPP
> package?
> I searched and searched but I couldn't find one. HELP ME!

Have you considered calling the constructor for int with your float as the
argument?

Like this?

int main()
{
    int i;
    float f;

    i = int(f); // calls the constructor for int with f as the argument
}

c people call this "type casting", and it has a slightly different syntax.

Or doesn't that do what you need?

--
Charles Krug, Jr.
Application Engineer
Pentek Corp
1 Park Way
Upper Saddle River, NJ 07458


- Raw text -


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