Hi there! As part of getting to know the language I am preparing the code for the softmax function and I just found out that the sum()
function does not return the expected result when some of the numbers of a vector are output in scientific notation. Here is the sample code:
julia> a =[23,4,56,7,2,1,9,4,3,2]
julia> exp.(a)
10-element Vector{Float64}:
9.744803446248903e9
54.598150033144236
2.091659496012996e24
1096.6331584284585
7.38905609893065
2.718281828459045
8103.083927575384
54.598150033144236
20.085536923187668
7.38905609893065
julia> sum(exp.(a))
julia> 2.0916594960130058e24
There is definitely something I miss from this very simple case of numerical computing, but I don’t seem to get it.
Any advice or hint are greatly appreciated!
PS: No similar topic is shown up in the similar topics’ section.