View comments | RSS feed

Round

Description

Rounds a number to the closest integer.

Return value

An integer.

Category

Mathematical functions

Syntax

Round(number)

See also

Ceiling, Fix, Int

Parameters

Parameter Description
number
Number to round

Example

<h3>Round Example</h3>
<p>This function rounds a number to the closest integer.
<ul>
  <li>Round(7.49) : <cfoutput>#Round(7.49)#</cfoutput>
  <li>Round(7.5) : <cfoutput>#Round(7.5)#</cfoutput>
  <li>Round(-10.775) : <cfoutput>#Round(-10.775)#</cfoutput>
  <li>Round(1.2345*100)/100 : 
  <cfoutput>#Evaluate(Round(1.2345*100)/100)#</cfoutput>
</ul>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


tom.e said on Nov 22, 2004 at 5:33 AM :
Round should be more precisely defined.

For example, Round returns the closest integer to the given number; for a fraction exactly halfway, it returns the next higher integer.

Round(3.5) => 4, Round(4.5) => 5, Round(-3.5) => -3, Round(-4.5) => 4

For reference, some languages use a "banking" round, which rounds up for odd numbers and down for even numbers.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt274.htm