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

Round up

How can I round up a float number?

For example:

If I have a number 3.6 I want to obtain 4 and

If I have a number 3.1 also to obtain 4

Thanks a lot.

Ruslan
Jul 19 '05 #1
4 8140
Ruslan wrote:
How can I round up a float number?


Math.Ceiling
Jul 19 '05 #2
add 0.5 and truncate?

Ruslan wrote:
How can I round up a float number?

For example:

If I have a number 3.6 I want to obtain 4 and

If I have a number 3.1 also to obtain 4

Thanks a lot.

Ruslan


Jul 19 '05 #3
Ruslan,
Have you tried System.Math.Ceiling? Which returns the smallest whole number
greater than or equal to the specified number.

Note for negative numbers it will return numbers closer to zero.

Ceiling(-3.6) will return -3.

The function System.Match.Floor will return the smallest whole number less
than or equal to the specified number.

Hope this helps
Jay

"Ruslan" <ru*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I round up a float number?

For example:

If I have a number 3.6 I want to obtain 4 and

If I have a number 3.1 also to obtain 4

Thanks a lot.

Ruslan

Jul 19 '05 #4
Thanks, Jay

It helped me.

Ruslan

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:#Q**************@TK2MSFTNGP12.phx.gbl...
Ruslan,
Have you tried System.Math.Ceiling? Which returns the smallest whole number greater than or equal to the specified number.

Note for negative numbers it will return numbers closer to zero.

Ceiling(-3.6) will return -3.

The function System.Match.Floor will return the smallest whole number less
than or equal to the specified number.

Hope this helps
Jay

"Ruslan" <ru*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I round up a float number?

For example:

If I have a number 3.6 I want to obtain 4 and

If I have a number 3.1 also to obtain 4

Thanks a lot.

Ruslan


Jul 19 '05 #5

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

Similar topics

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...
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...
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...
9
by: Ronald W. Roberts | last post by:
I'm having a problem understanding the Round function. Below are quotes from two books on VB.NET. The first book shows examples with one argument and how it rounds. The second book something...
4
by: Fuzzydave | last post by:
I have been using a round command in a few places to round a value to zero decimal places using the following format, round('+value+', 0) but this consistantly returns the rounded result of...
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...
3
by: Krishna.K.1900 | last post by:
Does round() always perfectly return the output expected or are there some artifacts which don't allow perfect functionality Using python 2.5: 12.23 12.234 12.199999999999999 but was...
4
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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
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...

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.