d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Question About Float Datatypes For C#
Add Reply New Topic New Poll
Member
Posts: 34,590
Joined: Mar 25 2009
Gold: 12,633.00
Aug 12 2015 11:02pm
I was wondering if someone could tell me the value range for different floating point data types....
float, double, & Decimal....minimum value to maximum value


what i mean by that is... for instance

sbyte = Integer between −128 and 127
byte = Integer between 0 and 255
ushort = Integer between 0 and 65535




Would really appreciate your guys help!!























well this is what i found of microsoft site:



float
1.175494351 E – 38
3.402823466 E + 38
double
2.2250738585072014 E – 308
1.7976931348623158 E + 308




which i'm not sure.... ehhh, so max value of a double is approx 309 with a decimal? Like you can only store a variable with double datatype as 309 with decimal as max value....? What about variables that need a higher value then 309?
Not really sure i understand it properly....
Member
Posts: 34,590
Joined: Mar 25 2009
Gold: 12,633.00
Aug 13 2015 12:05am
forgot to say:



float
1.175494351 E – 38 (minimum value)
3.402823466 E + 38 (Maximum Value)
double
2.2250738585072014 E – 308 (minimum value)
1.7976931348623158 E + 308 (maximum value)
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 13 2015 04:38am
short answer: use double, not float, and it can store most values of practical importance.

technical answer: it's scientific notation. E + 308 means times 10^308. but because of precision, not every value in that range can be stored. i believe it follows the IEEE format: https://en.wikipedia.org/wiki/Double-precision_floating-point_format
Member
Posts: 34,590
Joined: Mar 25 2009
Gold: 12,633.00
Aug 13 2015 03:14pm
Quote (carteblanche @ Aug 13 2015 06:38am)
short answer: use double, not float, and it can store most values of practical importance.

technical answer: it's scientific notation. E + 308 means times 10^308. but because of precision, not every value in that range can be stored. i believe it follows the IEEE format: https://en.wikipedia.org/wiki/Double-precision_floating-point_format


hmmm ok thanks so much man :)


what about decimal datatype?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 13 2015 03:26pm
Quote (ferf @ Aug 13 2015 05:14pm)
hmmm ok thanks so much man :)


what about decimal datatype?


read the documentation.

https://msdn.microsoft.com/en-us/library/system.decimal.aspx

Quote
Remarks
The Decimal value type represents decimal numbers ranging from positive 79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335. The Decimal value type is appropriate for financial calculations that require large numbers of significant integral and fractional digits and no round-off errors. The Decimal type does not eliminate the need for rounding. Rather, it minimizes errors due to rounding.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll