473,396 Members | 1,671 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,396 software developers and data experts.

how to always round numbers up

Hi,

Whats the easiest way to round numbers up.

For example, a calculation that results in a value of 1.3 will round to 1,
and a calculation that results in 1.8 will round to 2.

My issue that I want the 1.3 to always round up to 2, as to round down to 1
results is short supply of stock, which is worse than an over supply.

My only thoughts is to manually add 0.5 to every number and therefore it
would have that effect, but is there a better way to do this ?

Thanks

Mar 3 '08 #1
3 1809
Aussie,

In my idea is what you ask the integer value from X + .9999999999999999999

Cor
"Aussie Rules" <au****@nospam.comschreef in bericht
news:eJ**************@TK2MSFTNGP03.phx.gbl...
Hi,

Whats the easiest way to round numbers up.

For example, a calculation that results in a value of 1.3 will round to
1, and a calculation that results in 1.8 will round to 2.

My issue that I want the 1.3 to always round up to 2, as to round down to
1 results is short supply of stock, which is worse than an over supply.

My only thoughts is to manually add 0.5 to every number and therefore it
would have that effect, but is there a better way to do this ?

Thanks
Mar 3 '08 #2
Try Math.Ceiling

/claes

"Aussie Rules" <au****@nospam.comwrote in message
news:eJ**************@TK2MSFTNGP03.phx.gbl...
Hi,

Whats the easiest way to round numbers up.

For example, a calculation that results in a value of 1.3 will round to
1, and a calculation that results in 1.8 will round to 2.

My issue that I want the 1.3 to always round up to 2, as to round down to
1 results is short supply of stock, which is worse than an over supply.

My only thoughts is to manually add 0.5 to every number and therefore it
would have that effect, but is there a better way to do this ?

Thanks

Mar 3 '08 #3
"Aussie Rules" <au****@nospam.comschrieb
Hi,

Whats the easiest way to round numbers up.

For example, a calculation that results in a value of 1.3 will
round to 1, and a calculation that results in 1.8 will round to 2.

My issue that I want the 1.3 to always round up to 2, as to round
down to 1 results is short supply of stock, which is worse than an
over supply.

My only thoughts is to manually add 0.5 to every number and
therefore it would have that effect, but is there a better way to do
this ?

Math.Ceiling
Armin
Mar 3 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

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?
4
by: Bob Bryan | last post by:
I am using a select statement to obtain a result set back with aggregated data. The problem is that I am seeing column data with 11 to 13 digits after the decimal point. I tried using the STR...
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...
4
by: Chris Davoli | last post by:
The folllowing will round to 526, but it should round to 527. It works correctly for all other numbers, except for this one. Does anybody know of a bug in Math.Round? Dim ldecWater As Decimal =...
9
by: Lance Hoffmeyer | last post by:
Is there an easy way to round numbers in an array? I have Test = and want to round so the values are print Test
1
by: Richard Cranium | last post by:
Using the number 1.015 ***************************** the following script returns 1.02, which is correct var T; var S=new String(Math.round(parseFloat(1.015).toFixed(2)*100)); while...
13
by: Girish Sahani | last post by:
Hi, I want to truncate every number to 2 digits after the decimal point. I tried the following but it doesnt work. >>> a = 2 >>> b = 3 >>> round(a*1.0 / b,2) 0.67000000000000004
10
by: David Coleman | last post by:
I am running VS 2003 and have applied SP1. (On WinXP SP2, .Net 1.1) In the Command Window I get the following ? Math.Round(0.715, 2) 0.72 ? Math.Round(0.725, 2) 0.72 ? Math.Round(0.735, 2)...
7
by: kkmigas | last post by:
Can some one explain if this can be fixed using php.ini settings ? echo "round 20.545 -".round(20.545,2)."<br>"; echo "round 20.555 -".round(20.555,2)."<br>"; echo "number_format 20.545...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.