# Any suggestions for speeding this simple scalar function up?

**URL:** <https://discourse.julialang.org/t/any-suggestions-for-speeding-this-simple-scalar-function-up/66748>\
**Category:** Performance\
**Tags:** performance\
**Created:** [August 20, 2021, 8:19pm UTC](https://discourse.julialang.org/t/any-suggestions-for-speeding-this-simple-scalar-function-up/66748 "2021-08-20T20:19:06Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 21, 2021, 10:41am UTC](https://discourse.julialang.org/t/any-suggestions-for-speeding-this-simple-scalar-function-up/66748/22 "2021-08-21T10:41:32Z")

</div>

> [@Ahmed\_Salih](#):
>
> I found using “7” instead of “7.0” sped up the power calculation.

You sure?

```julia
julia> @btime ρ0 ^ γ setup = (ρ0 = 1000.0; γ = 7)
  85.486 ns (0 allocations: 0 bytes)
1.0e21

julia> @btime ρ0 ^ γ setup = (ρ0 = 1000.0; γ = 7.0)
  85.442 ns (0 allocations: 0 bytes)
1.0e21

```

Maybe that’s true when the exponent is a literal, or a small (\< 4) integer, but if you’re using a variable that is larger than 3, the exponent is converted to a float anyway

> [@DNF](#):
>
> Probably integer overflow for 1000^7

Ehr…

> [@giordano](#):
>
> What if gamma and rho0 are floats instead of integers that can overflow?

---

_[View the full topic](https://discourse.julialang.org/t/any-suggestions-for-speeding-this-simple-scalar-function-up/66748)._
