Floating point calculations on integers and integers multiplied by powers of 2 (e.g. `1.5`

) are actually *exact* until you exceed the maximum number of digits that are stored (52 bits), at which point their accuracy will degrade gracefully (making some errors in the least-significant bits). That happens around `n=7403`

for this calculation.

In contrast, working with `Int`

means that you will get catastrophic failure once you overflow 64 bits, which happens around `n == 80000`

for this calculation:

```
julia> square_of_sum(80000)
-8206488072109551616
julia> difference(80000)
-8206658741976231616
```

Broadening your signatures from `::Int`

to `::Integer`

, so that they accept any integer type, we can still get the exact answer (at considerably more expense) with `BigInt`

:

```
julia> difference(big(80000))
10240085331733320000
```

but doing this calculation in floating-point with `difference(n::AbstractFloat) = (1.5n^4 + n^3 - 1.5n^2 - n) / 6`

gives almost the right answer (to ≈16 significant digits) much more quickly:

```
julia> difference(80000.0)
1.024008533173332e19
julia> (difference(80000.0) - difference(big(80000))) / difference(big(80000))
-3.124973959038622594888003211964321226280055103023663464806989420192726958281252e-17
```