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

c++ - list<myClass<int> * > sort -

c - Defining floating point constants, how many digits are useful? -

C# Apple Bonjour - how to monitor service records within Windows -