Learn
LOLCODE allows converting a variable to a different types, such as from a NUMBAR
(float) to a NUMBR
(integer), using the IS NOW A
command.
It goes on a line between a variable’s name and a new type for the variable:
[variable] IS NOW A [type]
Casting a NUMBAR
to a NUMBR
truncates the decimal portion of the floating point number.
For example, in the code below:
I HAS A powerLevel ITZ 9000.1 powerLevel IS NOW A NUMBR
powerLevel
is changed to contain 9000
.
Instructions
1.
Create a variable named rating
and assign it a NUMBAR
(float) value.
Convert it to NUMBR
(integer) and print it with VISIBLE
.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.