ios - Wrong values for double in swift -


i have string value , converting double value adding it. shows different values when debugging. while using print statement shows correct values, when using "po" command in console shows different, getting different results expected one.

    let stringvalue = "83.84"     let doublevalue = double(stringvalue)     let floatvalue = float(stringvalue)      let decimalarray: array<double> = [doublevalue!, doublevalue!, doublevalue!]     let test1 = decimalarray.reduce(0, combine: +)      let floatarray: array<float> = [floatvalue!, floatvalue!, floatvalue!]     let test2 = floatarray.reduce(0, combine: +)      print(test1)     print(test2) 

i have attached image of console. please let me know how can resolved. enter image description here

i think using po before it's converting. put 1 breakpoint @ last line i.e. @ print(test2) , check.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -