# ERROR: LoadError: InexactError: Int64(Int64, 7.5)

**URL:** https://discourse.julialang.org/t/error-loaderror-inexacterror-int64-int64-7-5/74046
**Category:** New to Julia
**Tags:** question
**Created:** [January 4, 2022, 4:43pm UTC](https://discourse.julialang.org/t/error-loaderror-inexacterror-int64-int64-7-5/74046 "2022-01-04T16:43:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ConDor](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@ConDor](https://discourse.julialang.org/u/ConDor)
#### Post date: [January 4, 2022, 4:43pm UTC](https://discourse.julialang.org/t/error-loaderror-inexacterror-int64-int64-7-5/74046/1 "2022-01-04T16:43:18Z")

</div>

I am practising Julia on [techgig.com](http://techgig.com); there’s a ques name [Area of a Triangle](https://www.techgig.com/practice/question/area-of-a-triangle/eXlvOHVoR2E3L01RcFlXMFlRYi9RNUczaW56UW43dlFabSsyRXlIVEt1OGNuaFdNcngxaWw4bnloZW54UEZ2Sw==/1) in that I am getting an error

```julia
ERROR: LoadError: InexactError: Int64(Int64, 7.5)
Stacktrace:
 [1] Type at ./float.jl:700 [inlined]
 [2] convert(::Type{Int64}, ::Float64) at ./number.jl:7
 [3] top-level scope at none:0
 [4] include at ./boot.jl:317 [inlined]
 [5] include_relative(::Module, ::String) at ./loading.jl:1044
 [6] include(::Module, ::String) at ./sysimg.jl:29
 [7] exec_options(::Base.JLOptions) at ./client.jl:266
 [8] _start() at ./client.jl:425
in expression starting at /CandidateCode/CandidateCode.jl:9

```

It takes base and height as the input to get the area of the triangle in Int64 format, so after doing the multiplication (0.5 \* b \* h), I converted it to Int64 format. It gives an error for one test case where b=5 and height =3.

Code:

```julia
b,h = parse(Int64, readline()), parse(Int64, readline())
println(convert(Int64, 0.5*b*h))

```

Output for other test cases:

 ![Screenshot 2022-01-04 221042](https://global.discourse-cdn.com/julialang/original/3X/c/9/c9e9ca40184ee3a45c51fc2b0ae8d4e90e2872d2.jpeg)

---

<div class="post-metadata">

### Author: ![vettert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vettert/32/30599_2.png) [@vettert](https://discourse.julialang.org/u/vettert)
#### Post date: [January 4, 2022, 5:01pm UTC](https://discourse.julialang.org/t/error-loaderror-inexacterror-int64-int64-7-5/74046/2 "2022-01-04T17:01:44Z")

</div>

The error tells you that Julia can’t convert 7.5 into an integer (because it isn’t a whole number - makes sense).

In my opinion you should perform these calculations with Float64 as type.

---

<div class="post-metadata">

### Author: ![ConDor](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@ConDor](https://discourse.julialang.org/u/ConDor)
#### Post date: [January 4, 2022, 5:09pm UTC](https://discourse.julialang.org/t/error-loaderror-inexacterror-int64-int64-7-5/74046/3 "2022-01-04T17:09:45Z")

</div>

But for the input given base =16 and height = 10, if I didn’t convert it to Int64, it will provide 80.0, and that’s not the expected output. So for that, I used convert()

---

<div class="post-metadata">

### Author: ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)
#### Post date: [January 4, 2022, 5:48pm UTC](https://discourse.julialang.org/t/error-loaderror-inexacterror-int64-int64-7-5/74046/4 "2022-01-04T17:48:14Z")

</div>

Format the Float64 to match the spec instead of converting to an Int. Perhaps you can find examples here: [How to format float numbers in human-friendly format?](https://discourse.julialang.org/t/how-to-format-float-numbers-in-human-friendly-format/58209)
