comparison src/c/urweb.c @ 1920:2f33d9a51765

Increase precision for rendering floats to SQL
author Adam Chlipala <adam@chlipala.net>
date Tue, 03 Dec 2013 16:54:04 -0500
parents f5d1037effc9
children 1a04b1edded2 1e360ea06a09
comparison
equal deleted inserted replaced
1919:f5d1037effc9 1920:2f33d9a51765
1620 char *uw_Basis_attrifyFloat(uw_context ctx, uw_Basis_float n) { 1620 char *uw_Basis_attrifyFloat(uw_context ctx, uw_Basis_float n) {
1621 char *result; 1621 char *result;
1622 int len; 1622 int len;
1623 uw_check_heap(ctx, FLOATS_MAX); 1623 uw_check_heap(ctx, FLOATS_MAX);
1624 result = ctx->heap.front; 1624 result = ctx->heap.front;
1625 sprintf(result, "%g%n", n, &len); 1625 sprintf(result, "%.16g%n", n, &len);
1626 ctx->heap.front += len+1; 1626 ctx->heap.front += len+1;
1627 return result; 1627 return result;
1628 } 1628 }
1629 1629
1630 char *uw_Basis_attrifyString(uw_context ctx, uw_Basis_string s) { 1630 char *uw_Basis_attrifyString(uw_context ctx, uw_Basis_string s) {
2404 return "NULL"; 2404 return "NULL";
2405 else 2405 else
2406 return uw_Basis_sqlifyInt(ctx, *n); 2406 return uw_Basis_sqlifyInt(ctx, *n);
2407 } 2407 }
2408 2408
2409 char *uw_sqlfmtFloat = "%g::float8%n"; 2409 char *uw_sqlfmtFloat = "%.16g::float8%n";
2410 2410
2411 char *uw_Basis_sqlifyFloat(uw_context ctx, uw_Basis_float n) { 2411 char *uw_Basis_sqlifyFloat(uw_context ctx, uw_Basis_float n) {
2412 int len; 2412 int len;
2413 char *r; 2413 char *r;
2414 2414