# Will decreasing the precision of intermediate variables improve performance of code?

**URL:** https://discourse.julialang.org/t/will-decreasing-the-precision-of-intermediate-variables-improve-performance-of-code/39166
**Category:** Performance
**Tags:** performance
**Created:** [May 9, 2020, 6:27am UTC](https://discourse.julialang.org/t/will-decreasing-the-precision-of-intermediate-variables-improve-performance-of-code/39166 "2020-05-09T06:27:53Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![gcalderone](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gcalderone/32/1539_2.png) [@gcalderone](https://discourse.julialang.org/u/gcalderone)
#### Post date: [May 9, 2020, 8:11am UTC](https://discourse.julialang.org/t/will-decreasing-the-precision-of-intermediate-variables-improve-performance-of-code/39166/6 "2020-05-09T08:11:48Z")

</div>

Here’s an [example](https://discourse.julialang.org/t/performance-comparison-with-c/29682) of performances getting worse when performing `Float32` math involving an `Int64` loop variable.

The solution in that case was to explicitly use an `Int32` loop variable:

```julia
for i in Int32(1):N
  ...
end

```

However that `Int32(1)` is rather unpleasant to look at and, notably, very easy to forget with disastrous consequences.

---

_[View the full topic](https://discourse.julialang.org/t/will-decreasing-the-precision-of-intermediate-variables-improve-performance-of-code/39166)._
