In my postgres table I have a field which is type numeric (30,16)
where I store numbers with many decimals. I need to compute these numbers.
I am using knex
and by default it returns these values as String
so in order to have as number, I've tried:
var types = require('pg').types
types.setTypeParser(1700, 'text', parseFloat);
However this still doesn't work right, for instance from 488.1456218300001000
and I substract 300
I can obtain something like 188.1456218300001500
.
What do I need to do in node.js to properly handle operations without any rounding errors?