I like my svg to be really clean and I always hand tweak my drawings to make sure all objects are where I want them to be. One think i dont like is when doubles are printed like this:
x="200.000000" y="200.000000"
Is there are reason why we store more precision than necessary here? This value comes from sp_repr_set_double which uses sp_xml_dtoa. Doesn't sp_xml_dtoa do the same thing as printf %f formatting?
I have found that if I call sp_repr_set_double_attribute and replace the "%f" with a "%g" It will give a much cleaner output:
x="200" y="200"
Is there a technical reason why we have a custom dtoa function and keep the extra 0's?
Cheers, Rob. http://members.rogers.com/rcrosbie
_________________________________________________________________ Is there a gadget-lover on your gift list? MSN Shopping has lined up some good bets! http://shopping.msn.com
Robert Crosbie wrote:
I like my svg to be really clean and I always hand tweak my drawings to make sure all objects are where I want them to be. One think i dont like is when doubles are printed like this:
x="200.000000" y="200.000000"
Is there are reason why we store more precision than necessary here? This value comes from sp_repr_set_double which uses sp_xml_dtoa. Doesn't sp_xml_dtoa do the same thing as printf %f formatting?
I have found that if I call sp_repr_set_double_attribute and replace the "%f" with a "%g" It will give a much cleaner output:
x="200" y="200"
Is there a technical reason why we have a custom dtoa function and keep the extra 0's?
Is this to hack around the locale bug with ',' and '.' having swapped meanings in different languages/countries?
njh
On Sat, 29 Nov 2003, Robert Crosbie wrote:
I like my svg to be really clean and I always hand tweak my drawings to make sure all objects are where I want them to be. One think i dont like is when doubles are printed like this:
x="200.000000" y="200.000000"
Is there are reason why we store more precision than necessary here? This value comes from sp_repr_set_double which uses sp_xml_dtoa. Doesn't sp_xml_dtoa do the same thing as printf %f formatting?
I have found that if I call sp_repr_set_double_attribute and replace the "%f" with a "%g" It will give a much cleaner output:
x="200" y="200"
Is there a technical reason why we have a custom dtoa function and keep the extra 0's?
I have a dtoa routine I wrote a while ago that we may want to consider. It includes a provision for both sigfig and precision-based rounding which may be useful here. E.g.:
Number sf=4 p=-1 sf=4 p=2 sf=-1 p=3 ------ --------- -------- --------- 1.9999999 2 2.00 2.000 0.0008125 0.0008125 0.00 0.001
I find using sigfigs to make numerical output more concise without losing accuracy.
The code also includes a mechanism for 'Engineering notation' which is like Scientific notation (1.00E42) except that the exponents are in multiples of 3.
I also implemented a round() routine that follows the "rounding rule", that rounds numbers ending in 5 up half the time and down half the time, based on whether the preceding digit is even or odd. Example: Rounding off 3.45 and 3.55 by one decimal gives 3.4 and 3.6, respectively.
Bryce
participants (3)
-
Bryce Harrington
-
Nathan Hurst
-
Robert Crosbie