473,385 Members | 1,834 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 down

Hi,

How can I round down?

See this sample: 5 / 3 = 1.67
Now I want the answer/value 1.

Thanks!
Nov 17 '05 #1
3 13012
Hello!
How can I round down?
See this sample: 5 / 3 = 1.67
Now I want the answer/value 1.

You can use the Math.Floor() method.

double integerResult = Math.Floor(1.67);

--
Venlig hilsen
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP)
Nov 17 '05 #2
I think if you do integer calculations, that happens automatically. Or just
cast it to an integer.

"Arjen" <bo*****@hotmail.com> wrote in message
news:di**********@news2.zwoll1.ov.home.nl...
Hi,

How can I round down?

See this sample: 5 / 3 = 1.67
Now I want the answer/value 1.

Thanks!

Nov 17 '05 #3
Arjen <bo*****@hotmail.com> wrote:
How can I round down?

See this sample: 5 / 3 = 1.67
Now I want the answer/value 1.


Integer division in C# is always rounded towards zero. If that's all
you need, just do the division with integer operands.

If you need actual rounding *down* (even when the result is negative)
you probably want Math.Floor.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

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

Similar topics

3
by: db_guy | last post by:
<? $a=1.5345493; $b=round($a,2); echo "b: ".$b; ?> This code should return "b: 1.54", but instead returns "b: 1.53". Can anyone else confirm this?
9
by: joeandtel | last post by:
If I have a value that is 53.123499999, how can I round it to 53.12?
1
by: cody | last post by:
the documentation states that Math.Round supports banker's rounding but it also states that if the last number is 5 it will rounded up if the whole number is even, otherwise rounded down which is...
14
by: Nils Grimsmo | last post by:
Why did round() change in Python 2.4? $ python2.3 Python 2.3.5 (#2, Jun 19 2005, 13:28:00) on linux2 >>> round(0.0225, 3) 0.023 >>> "%.3f" % round(0.0225, 3) '0.023' >>>
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...
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)...
2
by: Tsair | last post by:
I found the decimal round up problem, System.Math.Round(106.865, 2)= 106.86 System.Math.Round(106.875, 2) = 106.88 System.Math.Round(106.885, 2) = 106.88 System.Math.Round(106.895, 2) = 106.9...
10
by: Henrootje | last post by:
I am looking for a way to round down the results of a calculation in a query f.e.: in a query this calculation is performed: a/b = c 5/3 = 1,666666667
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: 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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...

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.