2021年4月9日星期五

What would the need be to store a value with the precision of float in a double? (new to programming trying to polish my understanding on the basics)

So i understand that a double is more precise than a float and by storing a value as 'double x = 0.1f' i have the precision of float stored in a double. Why would i want to do this though instead of storing the value as a double like 'double x = 0.1' or as a float like 'float x = 0.1f'

When trying it in my IDE i see that 'double x = 0.1' and 'float x = 0.1f' both output 0.1 but 'double x = 0.1f' returns 0.10000000149011612. I dont understand the idea of whats happening.

https://stackoverflow.com/questions/67030669/what-would-the-need-be-to-store-a-value-with-the-precision-of-float-in-a-double April 10, 2021 at 12:01PM

没有评论:

发表评论