- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between a float, double and a decimal in C#?
Float , double and a decimal are all Value Types in C#.
Value type variables can be assigned a value directly. They are derived from the class System.ValueType. The value types directly contain data.
Float Value Type
Float is a 32-bit single-precision floating point type with range 3.4 x 1038 to + 3.4 x 1038
Memory Size is 4 bytes.
float a = 3.5f;
Double Value Type
Double is a 64-bit double-precision floating point type with range (+/-)5.0 x 10-324 to (+/-)1.7 x 10308
Memory Size is 8 bytes.
double d = 5.78788
Decimal Value Type
Decimal is a 128-bit precise decimal values with 28-29 significant digits with range (-7.9 x 1028 to 7.9 x 1028) / 100 to 28
Memory Size is 16 bytes.
decimal d = 1.0M;
Advertisements