delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/19/19:37:51

Date: Mon, 19 Jan 1998 19:37:27 -0500 (EST)
Message-Id: <199801200037.TAA05178@p2.acadia.net>
To: radon AT swipnet DOT se (Rikard Björklind)
Subject: Re: round
Cc: djgpp AT delorie DOT com
References: <34c3be38 DOT 741112 AT nntpserver DOT swip DOT net>
in-reply-to: <34c3be38.741112@nntpserver.swip.net>
From: swarnerx3 AT acadia DOT net (Scott Warner)
MIME-Version: 1.0

Something like

(int)((PI*sin(34)/43)+.5)

works for positive integers only, but I think

ceil(PI*sin(34)/43)

is part of the ANSI standard.  You'll have to cast to an int, since ceil() returns a double.

Hope that helps.


In message <34c3be38 DOT 741112 AT nntpserver DOT swip DOT net>, radon AT swipnet DOT se (Rikard Björklind) wrote:
> I want to know how to assign a double value to an int. Like this for
> example:
>
> int hej = (PI*sin(34)/43);
>
> I want the value rounded. Please help me I'm a beginner =).
>
>

- Raw text -


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