committed by
Aditya Bhargava
parent
c55036458e
commit
a15b071134
@@ -8,9 +8,9 @@ book["milk"] = 1.49
|
|||||||
book["avacado"] = 1.49
|
book["avacado"] = 1.49
|
||||||
print(book) // => ["avacado": 1.49, "apple": 0.67000000000000004, "milk": 1.49]
|
print(book) // => ["avacado": 1.49, "apple": 0.67000000000000004, "milk": 1.49]
|
||||||
|
|
||||||
// Qustion: Why is "apple" is 0.67000000000000004 intsted of 0.67?
|
// Qustion: Why is "apple" is 0.67000000000000004 instead of 0.67?
|
||||||
// Answer: Double cannot store the value 0.67 exactly. Swift uses (like many other languages) binary floating point numbers according to the IEEE 754 standard.
|
// Answer: Double cannot store the value 0.67 exactly. Swift uses (like many other languages) binary floating point numbers according to the IEEE 754 standard.
|
||||||
// This topic is not related with Algorithms, but you can play with .description and .debugDescription for making workarrounds
|
// This topic is not related to Algorithms, but you can play with .description and .debugDescription for making workarounds
|
||||||
print(book["apple"]?.description ?? "Not exist") // => 0.67
|
print(book["apple"]?.description ?? "Not exist") // => 0.67
|
||||||
print(book["apple"]?.debugDescription ?? "Not exist") // => 0.67000000000000004
|
print(book["apple"]?.debugDescription ?? "Not exist") // => 0.67000000000000004
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user