1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +00:00

(trunk libT) prevent potential rounding errors when sending floating-point numbers across the wire in json form

This commit is contained in:
Charles Kerr 2009-08-03 23:18:02 +00:00
parent 87a7bf043a
commit 723cabb542

View file

@ -1301,7 +1301,7 @@ jsonRealFunc( const tr_benc * val, void * vdata )
/* json requires a '.' decimal point regardless of locale */
tr_strlcpy( locale, setlocale( LC_NUMERIC, NULL ), sizeof( locale ) );
setlocale( LC_NUMERIC, "POSIX" );
evbuffer_add_printf( data->out, "%.4f", val->val.d );
evbuffer_add_printf( data->out, "%.4f", tr_truncd( val->val.d, 4 ) );
setlocale( LC_NUMERIC, locale );
}