473,385 Members | 1,353 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.

Rounding decimals to interger

i would like to know how can i round to next greater than integer if
not integer already
what i mean is:

5.00000000000000000000000001 rounded to 6
5.1 rounded to 6
5.7 rounded to 6
6.0 rounded to 6
5.0 rounded to 5
as long as the value have something in decimal round it to the nearest
integer greater than

Oct 16 '07 #1
3 1342
"Franck" <th***********@hotmail.comschrieb im Newsbeitrag
news:11**********************@q3g2000prf.googlegro ups.com...
>i would like to know how can i round to next greater than integer if
not integer already
what i mean is:

5.00000000000000000000000001 rounded to 6
5.1 rounded to 6
5.7 rounded to 6
6.0 rounded to 6
5.0 rounded to 5
as long as the value have something in decimal round it to the nearest
integer greater than
use Math.Ceiling

Christof

Oct 16 '07 #2
On Oct 16, 11:29 am, "Christof Nordiek" <c...@nospam.dewrote:
"Franck" <the_darkbl...@hotmail.comschrieb im Newsbeitragnews:11**********************@q3g2000pr f.googlegroups.com...
i would like to know how can i round to next greater than integer if
not integer already
what i mean is:
5.00000000000000000000000001 rounded to 6
5.1 rounded to 6
5.7 rounded to 6
6.0 rounded to 6
5.0 rounded to 5
as long as the value have something in decimal round it to the nearest
integer greater than

use Math.Ceiling

Christof
Works. i was trying whit split and everything :P but the problem was
depending on country the decimal symbol can be a dot or a comma. that
ceilling simplyfied my life there

Oct 16 '07 #3
On Oct 16, 11:20 am, Franck <the_darkbl...@hotmail.comwrote:
i would like to know how can i round to next greater than integer if
not integer already
what i mean is:

5.00000000000000000000000001 rounded to 6
5.1 rounded to 6
5.7 rounded to 6
6.0 rounded to 6
5.0 rounded to 5
as long as the value have something in decimal round it to the nearest
integer greater than
Hi Franck,
You could use Math.Ceiling, like this:

decimal[] d = { 5.00000000000000000000000001M, 5.1M, 5.7M, 6.0M,
5.0M };
decimal[] d2 = new decimal[d.Length];
for (int i = 0; i < d.Length; i++)
d2[i] = Math.Ceiling(d[i]);

John

Oct 16 '07 #4

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

Similar topics

5
by: astro | last post by:
I have a report/invoice that lists volume, price per unit, and extended price. My problem is being able to get the extended price by multiplying the x . With just 2 decimal places on both...
206
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.