1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

using MongoDB.Bson;
using MongoDB.Bson.DefaultSerializer;
using MongoDB.Bson.IO;
using MongoDB.Bson.Serialization;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using System.Xml;
using System.Collections;
using System.Text;

using MongoDB.Bson;
using MongoDB.Driver;

namespace ConsoleApplication1 {
    public static class Program {
        public static void Main(string[] args) {
            var server = MongoServer.Create("mongodb://localhost");
            var database = server["test"];
            var collection = database["test"];

            var x = double.Parse("12.444057295828145");
            var y = double.Parse("12.63416004180907");

            var document = new BsonDocument { { "x", 0.0 }, { "y", 0.0 } };
            collection.RemoveAll();
            collection.Insert(document);
            var id = document["_id"].AsObjectId;

            collection.Update(
                Query.EQ("_id", id),
                Update.Set("x", x).Set("y", y)
            );

            var doc = collection.FindOne();
            if (x == doc["x"].AsDouble) {
                Console.WriteLine("No loss of precision in x value");
            }
            if (y == doc["y"].AsDouble) {
                Console.WriteLine("No loss of precision in y value");
            }

            Console.WriteLine("Press Enter to continue");
            Console.ReadLine();
        }
    }
}