# Error in my code

**URL:** <https://discourse.julialang.org/t/error-in-my-code/104930>\
**Category:** New to Julia\
**Created:** [October 13, 2023, 2:13pm UTC](https://discourse.julialang.org/t/error-in-my-code/104930 "2023-10-13T14:13:16Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [October 13, 2023, 2:30pm UTC](https://discourse.julialang.org/t/error-in-my-code/104930/4 "2023-10-13T14:30:42Z")

</div>

Dividing two integers can result in a non-integer.

```julia-repl
julia> 4/3
1.3333333333333333

```

You are then trying to put that non-integer into an array of integers, but Julia doesn’t know how you want to round it, so it throws an `InexactError`.

```julia-repl
julia> Int[4/3]
ERROR: InexactError: Int64(1.3333333333333333)

```

You need to round the result yourself first.

```julia-repl
julia> Int[round(Int,4/3)] # round to nearest
1-element Vector{Int64}:
 1

julia> Int[ceil(4/3)] # round up
1-element Vector{Int64}:
 2

julia> Int[floor(4/3)] # round down
1-element Vector{Int64}:
 1

```

Please read [this post](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) to make it easier to help you next time. (It is hard to read your code and the plotting lines are irrelevant to your problem.)

---

_[View the full topic](https://discourse.julialang.org/t/error-in-my-code/104930)._
