Hi,
Is there a way of calculating sum if one of values is NaN?
Example:
sum = a + b + c where c is NaN.
Can it be ignored somehow?
Thank you.
Hi,
Is there a way of calculating sum if one of values is NaN?
Example:
sum = a + b + c where c is NaN.
Can it be ignored somehow?
Thank you.
Go doesn’t allows you to do operations with any value that it NaN
, the result will always come out to be NaN
, you will have to check each value whether it is NaN
or not
To check for NaN
, you can use this function
https://golang.org/pkg/math/#IsNaN
If it is NaN
, then ignore it in operation or make it 0
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.