-5

What is the difference between Math.Floor() and Math.Truncate() in .NET?

e.g. Math.Floor(5.4) = 5 Math.Truncate(5.4) = 5 – subramani

NikNek
  • 9
  • 1
  • 3

1 Answers1

0

Floor(-2.1) will result in -3,
while Truncate(-2.1) will result in -2.

Truncate "cuts" off after the decimal point.
Floor on the other hand is a mathematical function that rounds downwards to the nearest integer.

Raildex
  • 3,406
  • 1
  • 18
  • 42
  • You answer only tells the OP what the output of those functions will be, not why it is that those functions output those values. Consider editing your answer to give OP insight into why the outputs of the functions differ. – Timotheus May 31 '21 at 07:59