Trunc Method in Delphi

I am porting some code to .Net, and I realized that the Trunc method does not work properly in Delphi. It does not take into account whether you are truncating a negative or positive value. He views the argument as absolute.

Delphi

Trunc(-163.78999) returns -163

. Network deployment

System.Math.Floor(-163.88888888888889) returns -164.

I can imitate implementations, but I wonder if anyone has seen this before.

Thank,

+4
source share
1 answer

Delphi Truncfunction executes as designed. The documentation says (my attention):

Truncates a real number to an integer.

Delphi Trunc . X - . Trunc Int64, , X .

.net Delphi Trunc Math.Truncate.

, .net System.Math.Floor, Floor.

+9

All Articles