473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

round function

what is the header file when we are dealing with round function. or it haven't a header file,so you can tell me how we work with round function
Feb 21 '07 #1
3 10431
There are two functions are available ceil() and floor() both functions are defined in the math.h header file

ceil() function will round of the value near to the highest i.e 12.54 as 13.00
floor() function will round of the value near to the smallest i.e 12.54 as 12.00

Both the function will take arguments as double or long double and return the same type of value....
Feb 21 '07 #2
horace1
1,510 Expert 1GB
what is the header file when we are dealing with round function. or it haven't a header file,so you can tell me how we work with round function
don't know of a function called round() - are you thinking of ceil(x) which returns the smallest integer no less than x, see
http://www.cppreference.com/stdmath/index.html
Feb 21 '07 #3
DeMan
1,806 1GB
Assuming you want to round in the traditional way 0.5 or greater goes to 1
less than 0.5 rounds to 0, you can use try adding .5 and calling floor (or subtracting 0.5 and czalling ceil())

Expand|Select|Wrap|Line Numbers
  1. float myVariable = 7.3
  2. myVariable = myVariable +0.5
  3. floor(myVariable):
  4. //result = 7
  5.  
  6. OR
  7.  
  8. float myVariable = 7.3
  9. myVariable = myVariable -0.5
  10. ceil(myVariable):
  11. //result = 7
  12.  
  13.  
Feb 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: joeandtel | last post by:
If I have a value that is 53.123499999, how can I round it to 53.12?
6
by: Jef Driesen | last post by:
I need to implement a function to implement the rounding of floating point values. At the moment i have two different implementations, depending on the type of the return value (integer or double)....
2
by: Matias Silva | last post by:
Can anybody tell me why I am getting rounding errors using the ROUND function. 3.7125 rounds to 3.70 when I use the following: TRUNCATE(ROUND(units_pay_amount * fees_amount, 2),2))) The correct...
3
by: shank | last post by:
I have the following equation. <% varWT = Round(CInt((rsFreePack.Fields.Item("Weight").Value)) + CInt(Session("w"))) %> Assume.... Round(CInt((rsFreePack.Fields.Item("Weight").Value)) = .12...
6
by: Penguin | last post by:
At some long ago time Steve Jorgensen answered thus: Subject: Re: How can I round a time? Newsgroups: comp.databases.ms-access Date: 1998/12/11 Access represents a date internally as a double...
3
by: ORC | last post by:
Is there a round function that do a "Normal" rounding and not the round to nearest as the Math.Rounds is? Math.Round(3.44, 1); //Returns 3.4. Math.Round(3.45, 1); //Returns 3.4....
17
by: nomenklatura | last post by:
Hi, System.Math.Round function is confused me. for example i want to round 3.245 in with decimal symbol Result should be = 3.25 When i try to this in vb: A = 3.245 X = Round(A, 2) then...
21
by: Karl O. Pinc | last post by:
FYI, It'd be nice if the error message from a REFERENCES constraint mentioned the column name into which the bad data was attempted to be inserted. In PostgreSQL 7.3: sandbox=> insert into...
3
by: Altman | last post by:
OK I was having rounding problems before and I didn't realize that their was a third parameter in the round function that would tell it if it a 5 to round up. I thought adding this would fix the...
9
by: josh logan | last post by:
Hello, I need a round function that _always_ rounds to the higher integer if the argument is equidistant between two integers. In Python 3.0, this is not the advertised behavior of the built-in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.