Skip to main content
Skip table of contents

round() Operation

Syntax

set aFloat = aFloat.round(base)

Semantics

Rounds float to a given base. The result is of type Float.

If you want to remove the fraction then base is 1.0. The common method is implemented:

  • Decide which is the last digit to keep.

  • Increase it by 1, if the next digit is 5 or more (this is called rounding up).

  • Leave it the same, if the next digit is 4 or less (this is called rounding down).
    See also Rounding on Wikipedia.

Substitutables

aFloat

Can be any variable or object attribute having the type Float

base

Is of type Float and encodes the base to be rounded to. For examples, see the table below.

Examples

CODE
set aFloat1 = aFloat1.round(2); 
set aFloat2 = aFloat3.round(aFloat4);

Some Examples

aFloat

Base

Rounding Result

3.1

1.0

3

3

1.0

3

3.499

1.0

3

3.999

1.0

4

3.5

1.0

4

3.501

1.0

4

-3.1

1.0

-3

-3

1.0

-3

-3.499

1.0

-3

-3.999

1.0

-4

-3.5

1.0

-4

-3.501

1.0

-4

999999999999999999999999999.499

0.001

999999999999999999999999999.499

3.499

0.001

3.499

3.499

0.01

3.5

3.499

0.1

3.5

3.499

0.5

3.5

3.499

1.0

3

3.499

10.0

0

-3.499

0.001

-3.499

-3.499

0.01

-3.5

-3.499

0.1

-3.5

-3.499

0.5

-3.5

-3.499

1.0

-3

-3.499

10.0

0

ActionScript_TypeConversions_Example

Click here to download a simple example model that different possibilities for type conversions between Float, Integer, String, and Boolean types in Scheer PAS Designer.

Related Documentation:

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.