Thank you very much for your replies @LukeF
After using your code in a separate instance of project, it does work!! So this is when I wondered which part in my code is different? - and that’s how I stored and checked the data. You stored and checked the data with session states and I checked and stored it with a database.
And so I realised the problem might’ve been how my database (phpMyAdmin) stored the data. I used “float” type instead of “double”. And I found this thread in stackoverflow. It shows my exact problem with the data being rounded off after the 6-7th unit.
“float” type has 6-7 significant digits
“double” type has 16 significant digits
TL; DR: My main issue lies with how my database stored the data. After changing it to “double” type, I’ve increased the precision and can now store larger values. I guess my problem for the future is when i need more than 16 significant digits, but this isnt a streamlit problem anymore. Thanks for helping me realise this @LukeF