--
You received this message because you are subscribed to the Google Groups "BSON" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bson+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
$ ./bson_float_test
double: 0.01000000000000000021
float: 0.00999999977648258209
{ "double" : 0.010000000000000000208, "float_cast" : 0.0099999997764825820923 }
/// cc -o bson_float_test bson_float_test.c -lbson-1.0.0
#include <stdio.h>
#include <libbson-1.0/bson.h>
int main(int argc, const char* argv[])
{
bson_t b;
bson_init(&b);
double dvalue = 0.01;
printf("double: %0.20f\n", dvalue);
bson_append_double(&b, "double", -1, dvalue);
float fvalue = 0.01f;
printf("float: %0.20f\n", fvalue);
bson_append_double(&b, "float_cast", -1, (double)fvalue);
char* json = bson_as_json(&b, NULL);
printf("%s\n", json);
bson_free(json);
return 0;
}
To unsubscribe from this group and stop receiving emails from it, send an email to bson+unsubscribe@googlegroups.com.