# How to compute the smallest integer number strictly greater than a given number?

**URL:** <https://discourse.julialang.org/t/how-to-compute-the-smallest-integer-number-strictly-greater-than-a-given-number/1304>\
**Category:** Numerics\
**Created:** [January 5, 2017, 3:52pm UTC](https://discourse.julialang.org/t/how-to-compute-the-smallest-integer-number-strictly-greater-than-a-given-number/1304 "2017-01-05T15:52:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [January 5, 2017, 3:52pm UTC](https://discourse.julialang.org/t/how-to-compute-the-smallest-integer-number-strictly-greater-than-a-given-number/1304/1 "2017-01-05T15:52:30Z")

</div>

Is there a Julia function that returns the smallest integer number strictly greater than a given number? For example, if I give `0.5`, it returns me `1.0`. If I give `1.0`, it returns `2.0`? `ceil()` can do the former example for sure, but for the latter example, it just returns me `1.0`.

By integer, I mean the `Float64` representation of an integer, not any `Int` type. Thanks!

---

<div class="post-metadata">

**Author:** ![harven](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@harven](https://discourse.julialang.org/u/harven)\
**Post date:** [January 5, 2017, 4:02pm UTC](https://discourse.julialang.org/t/how-to-compute-the-smallest-integer-number-strictly-greater-than-a-given-number/1304/2 "2017-01-05T16:02:31Z")

</div>

`floor + 1`?

```
julia> blah(x) = floor(x) + 1
blah (generic function with 1 method)
julia> blah(0.5)
1.0
julia> blah(1.0)
2.0
julia> blah(0.9)
1.0
julia> blah(-.5)
0.0
julia> blah(-1.0)
0.0

```

---

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [January 5, 2017, 4:04pm UTC](https://discourse.julialang.org/t/how-to-compute-the-smallest-integer-number-strictly-greater-than-a-given-number/1304/3 "2017-01-05T16:04:49Z")

</div>

Brilliant!! Thanks!!

---

<div class="post-metadata">

**Author:** ![garrison](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrison/32/209519_2.png) [@garrison](https://discourse.julialang.org/u/garrison)\
**Post date:** [January 14, 2017, 2:48am UTC](https://discourse.julialang.org/t/how-to-compute-the-smallest-integer-number-strictly-greater-than-a-given-number/1304/5 "2017-01-14T02:48:30Z")

</div>

Not sure if it matters for your use case, but `f(x) = floor(Int, x) + 1` would be a bit more robust, as not all integers can be represented as floating point

```julia
julia> f(x) = floor(Int, x) + 1
f (generic function with 1 method)

julia> g(x) = floor(x) + 1
g (generic function with 1 method)

julia> 2^53
9007199254740992

julia> f(float(2^53))
9007199254740993

julia> Int(g(float(2^53)))
9007199254740992

```
