0
0
PowerShellscripting

Integer and floating-point types in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an integer type in PowerShell?
An integer type is a number without decimals. It can be positive or negative, like 5 or -10.
Click to reveal answer
beginner
What is a floating-point type in PowerShell?
A floating-point type is a number that can have decimals, like 3.14 or -0.5.
Click to reveal answer
beginner
How do you declare an integer variable in PowerShell?
You can declare an integer by assigning a whole number to a variable, for example: $num = 10
Click to reveal answer
beginner
How do you declare a floating-point variable in PowerShell?
You declare it by assigning a decimal number to a variable, for example: $num = 3.14
Click to reveal answer
intermediate
What happens if you add an integer and a floating-point number in PowerShell?
PowerShell converts the integer to floating-point and adds them, keeping the decimal part.
Click to reveal answer
Which of these is an integer in PowerShell?
A42
B3.14
C"42"
DTrue
What type is the number 7.0 in PowerShell?
AInteger
BString
CBoolean
DFloating-point
How does PowerShell treat the expression 5 + 2.5?
AAs floating-point addition
BAs integer addition
CAs string concatenation
DAs an error
Which variable assignment creates a floating-point number?
A$x = 10
B$x = 10.0
C$x = '10'
D$x = $true
What is the output type of this code? `$a = 3; $b = 4.5; $c = $a + $b`
AInteger
BBoolean
CFloating-point
DString
Explain the difference between integer and floating-point types in PowerShell.
Think about numbers you use in daily life like 5 vs 3.14.
You got /3 concepts.
    Describe what happens when you add an integer and a floating-point number in PowerShell.
    Consider how 5 + 2.5 becomes 7.5.
    You got /3 concepts.