# Floor and Ceiling

## Recommended Posts

1) I was not aware of the UDF's prior to writing the built-ins. (Yes, I am the idiot that wrote the built-in functions. )

2) Floor() and Ceiling() directly call standard C functions, instead of working around in AutoIt. This makes the built-in functions much faster and easier on the system from the UDF's.

I would recommend that if you are going to be using the beta, use Floor() and Ceiling(), but if your code could be run on the release version, use the UDF's (for now).

Edit: Stupid speeling errors!

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

##### Share on other sites

Continuing the thread started here, Int, Round, Ceiling and Floor have related but different behaviours.

Int truncates decimals, giving a result that is closer to 0, or the same if no decimals.

```Int(4.8) = 4
Int(4.5) = 4
Int(4.3) = 4
Int(4) = 4
Int(-4) = -4
Int(-4.3) = -4
Int(-4.5) = -4
Int(-4.8) = -4```

Round rounds to the nearest integer (or whatever scale you give).

```Round(4.8) = 5
Round(4.5) = 5
Round(4.3) = 4
Round(4) = 4
Round(-4) = -4
Round(-4.3) = -4
Round(-4.5) = -5
Round(-4.8) = -5```

Floor always rounds down. The number returned is the largest integer less than or equal to the parameter.

```Floor(4.8) = 4
Floor(4.5) = 4
Floor(4.3) = 4
Floor(4) = 4
Floor(-4) = -4
Floor(-4.3) = -5
Floor(-4.5) = -5
Floor(-4.8) = -5```

Ceiling always rounds up. The number returned is the smallest integer greater than or equal to the parameter.

```Ceiling(4.8) = 5
Ceiling(4.5) = 5
Ceiling(4.3) = 5
Ceiling(4) = 4
Ceiling(-4) = -4
Ceiling(-4.3) = -4
Ceiling(-4.5) = -4
Ceiling(-4.8) = -4```

Keep in mind that negative numbers are reversed in order from positive numbers.

So, -4 > -4.3

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

##### Share on other sites

Wow.. I feel pretty foolish right now. See, what I saw in the post update for .44, that Ceil and Floor functions were included, I checked my help file (which HADN'T been updated yet) and saw the _Ceil, and _Floor UDFs (which I had not noticed before), so when I tried them, that's when I came up with erroneous results, hence my post on the beta thread saying that Ceil was faulty... No wonder nobody addressed my concern, I was wrong!

If I could delete those posts, I would.

##### Share on other sites

so the udf _floor & _ceil will be removed on the next beta release ?

<{POST_SNAPBACK}>

More likely the next official release.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

##### Share on other sites

• Developers

so the udf _floor & _ceil will be removed on the next beta release ?

<{POST_SNAPBACK}>

More likely the next official release.

<{POST_SNAPBACK}>

Nah, don't think we should remove it yet for backwards compatibility.

But will remove it from the Helpfile when this release becomes official.

SciTE4AutoIt3 Full installer Download page   - Beta files

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Nah, don't think we should remove it yet for backwards compatibility.

But will remove it from the Helpfile when this release becomes official.

<{POST_SNAPBACK}>

Works for me.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ### Recently Browsing   0 members

• No registered users viewing this page.
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...