From 524701caad360795a718b38b0d17946dca0665fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 22 Apr 2016 04:46:54 +0200 Subject: [PATCH] README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2b341657c..286aa90b6 100644 --- a/README.md +++ b/README.md @@ -961,16 +961,16 @@ A classic technique is to store *integers* instead, since SQLite performs exact ```swift // Store -let amount = NSDecimalNumber(string: "0.1") -let integerAmount = amount +let amount = NSDecimalNumber(string: "0.1") // 0.1 +let integer = amount // 100 .decimalNumberByMultiplyingByPowerOf10(2) .longLongValue // INSERT INTO transfers (amount) VALUES (100) -try db.execute("INSERT INTO transfers (amount) VALUES (?)", arguments: [integerAmount]) +try db.execute("INSERT INTO transfers (amount) VALUES (?)", arguments: [integer]) // Read -let integerAmount = Int64.fetchOne(db, "SELECT SUM(amount) FROM transfers")! -let amount = NSDecimalNumber(longLong: integerAmount) +let integer = Int64.fetchOne(db, "SELECT SUM(amount) FROM transfers")! // 100 +let amount = NSDecimalNumber(longLong: integer) // 0.1 .decimalNumberByMultiplyingByPowerOf10(-2) ```