+ 1
I do not understand the bool .char and double..I want to know their functions pls any help
2 odpowiedzi
+ 13
boolean has two states true or false.
char is a single character like b
double is a number with a decimal like 2.5
+ 2
Oh and to elaborate on what he said, double isn't the same as decimal, decimal has a longer range of decimal numbers than double does. It is more precise however takes more bytes. Also float is a smaller range than double. So if you need to use decimals depending on how big the range you need it to be from least to greatest (in range and in the amount of memory taken up due to it):
(Note: when declaring variables you can indeed use var but when you don't need a huge range and make it a decimal it will read it automatically read as a double)
Float
Ex of declaring variable:
Float variableExample = 3.5f
(if you don't put the f the program will think it's a double and it say it can't be implicitly converted I think)
Double
Ex of declaring variable:
Double variableOther = 3.5d
Decimal
Ex of declaring variable:
Decimal variableSomething = 3.5m
Appendage:
When using var to declare your variables and you set it equal to a decimal it will assume it's double unless you put the f
Ex of whats a double:
var decimalVariable = 3.7
Ex of what's a float:
var decimalVariable =3.7f