In Postgresql
select 4/100;
returns 0 instead of 0.04
There is more than one way to solve this problem.
A. select 4/100.0;
It will return 0.04000000000000000000.
If you want to keep only x digits after the decimal points, use
select round(4/100.0, x);
For example, select round(4/100.0, 2) will return 0.04.
B. select cast(4 as decimal)/100;
It will also return 0.04000000000000000000.
C. select cast(4 as float)/100;
This will return 0.04.
select 4/100;
returns 0 instead of 0.04
There is more than one way to solve this problem.
A. select 4/100.0;
It will return 0.04000000000000000000.
If you want to keep only x digits after the decimal points, use
select round(4/100.0, x);
For example, select round(4/100.0, 2) will return 0.04.
B. select cast(4 as decimal)/100;
It will also return 0.04000000000000000000.
C. select cast(4 as float)/100;
This will return 0.04.
-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.
No comments:
Post a Comment