Question: What is the difference between
Solution:
Returns the largest integer less than or equal to the specified number.
Calculates the integral part of a number.
Example with outputs
Math.Floor()
and Math.Truncate()
in .NET?Solution:
math.floor()
Returns the largest integer less than or equal to the specified number.
math.truncate()
Calculates the integral part of a number.
Example with outputs
Math.Floor(2.56) = 2 Math.Floor(3.22) = 3 Math.Floor(-2.56) = -3 Math.Floor(-3.26) = -4 Math.Truncate(2.56) = 2 Math.Truncate(2.00) = 2 Math.Truncate(1.20) = 1 Math.Truncate(-3.26) = -3 Math.Truncate(-3.96) = -3
No comments:
Post a Comment