I am trying to store 145.19064169678300
decimal value in database but when I look into database the last 3 digits are different and stored value is 145.19064169678299
. My migration file looks like this
t.decimal :latitude, null: false, precision: 18, scale: 15
For value 145.449895817713000
it is stored as 145.449895817713013
How can I store the exact value without any rounding ? I am using postgres as database.
CodePudding user response:
Are you viewing the csv file in Excel?
Are you sure Excel isn't rounding the display?
Excel, in its attempts to be "helpful" can distort the display of data, and change the underlying data if you edit the file. It drops leading 0s, rounds numbers or converts them to scientific notation. Best to stick with plain text editors when working with CSV or TSV files.