Why is exponent (0.0) a DomainError?

Why exponent(0.0)gives a domain error? It seems that the exponent 0.0should be the same as the exponent 1.0, which is 0. Since zero is Int, I am confused why this would be outside the domain (or is it an error? An error has been fixed here, it seems to be a conscious choice) .

+3
source share
1 answer

Lets play with values ​​to see:

julia> exponent(2.0)                                                                                                                                       
1 --- 2^1 = 2

julia> exponent(4.0)                                                                                                                                       
2 --- 2^2 = 4

julia> exponent(1.0)                                                                                                                                       
0 --- 2^0 = 1

julia> exponent(0.5)                                                                                                                                       
-1 --- 2^-1 = 0.5

julia> exponent(0.25)                                                                                                                                       
-2 --- 2^-2 = 0.25

.
.
.

So this means:

julia> exponent(0.0)                                                                                                                                       
-∞ --- 2^-∞ = 0.0

Negative infinity causes a domain error.

+5
source

Source: https://habr.com/ru/post/1655558/


All Articles