- Home /
How do I preserve float accuracy in transform.position?
I'm making a program where the position and location of the player is tracked and saved in a text file to be read later. For some reason when I save the position data so:
posData.Add(transform.position.ToString() + " : " + transform.rotation.eulerAngles.ToString());
the floats for X Y and Z are all rounded down to a single decimal point.
I could fix this by multiplying every number by 100 and dividing again on the other side but that feels sloppy. Is there a way to preserve the other 6 decimal points of data?
Comment
Answer by _Yash_ · Oct 29, 2014 at 06:26 AM
ToString of Vector3 do rounds the number.
to get precise value of each element of vector 3 you have to do position.x.ToString() and same for y and z and then concatenate the string the way you want.
Your answer
![](https://koobas.hobune.stream/wayback/20220613170228im_/https://answers.unity.com/themes/thub/images/avi.jpg)