Search C # (value type 4) C # Talent Bird (QQ: 249178521)
9. Floating point type
Types of
Bit number
SYSTEM.
Compatible with CLS?
suffix
Float
32
Single
Yes
F F
Double
64
Double
Yes
Di
C # default floating point type is Double, so you have to use a float type, you must add f or f after the digital rear.
123.F is wrong because C # thinks this will cause ambiguity. F is 123. This floating point suffix is still a function of the 123 INT class instance? The C # compiler thinks this is a mistake, because the int class does not have a method!
10. Operator of floating point number
Most operators and integers
W Aging% is allowed (not allowed in C / C )
W shift operator is not allowed
Floating point calculation does not throw an error
W Small results will be converted to 0
W big result will be converted to /- infinity
W Invalid operation, the result will be converted to nan
W as long as one opera is nan, the result is turned into nan
11. Conversion of floating point numbers
Float is converted to Double
W implicit conversion
W Will not throw an error
Double to float
w Explicit conversion
W Will not throw an error
Integer to floating point
W implicit conversion
W Will not throw an error
w will lose the accuracy, but will not change the size
Floating point number is integer
w Explicit conversion
W may throw overflow errors