Recent

Author Topic: [SOLVED] Why doesn't the 'int' function return an integer value?  (Read 4775 times)

tetrastes

  • Hero Member
  • *****
  • Posts: 737
Re: [SOLVED] Why doesn't the 'int' function return an integer value?
« Reply #30 on: November 15, 2024, 10:02:02 pm »
@Warfley
You didn't comment the picture of Microsoft calculator. It thinks that round(2.5) = 3, BTW  ;)

tetrastes

  • Hero Member
  • *****
  • Posts: 737
Re: [SOLVED] Why doesn't the 'int' function return an integer value?
« Reply #31 on: November 21, 2025, 11:25:52 pm »
This is not for restarting the discussion, but I think it's worth to note.

From ISO 7185 Pascal (point 6.6.6.3) and ISO 10206 Extended Pascal (6.7.6.3):
Quote
round(x)
From the expression x that shall be of real-type, this function shall return a result of integer-type.
If x is positive or zero, round(x) shall be equivalent to trunc(x+0.5); otherwise, round(x)
shall be equivalent to trunc(x-0.5).

And indeed, in modes ISO and ExtendedPascal the result of round(2.5) is 3.

Ten_Mile_Hike

  • Full Member
  • ***
  • Posts: 132
Re: [SOLVED] Why doesn't the 'int' function return an integer value?
« Reply #32 on: January 07, 2026, 10:04:18 pm »
When I first read the original post I thought that the question was... why is the function called "Int"; couldn't it be better named so as to avoid bugs when you don't "think" that you have to RTFM.

NOTE: I am NOT saying this. I am saying that this is how I interpreted the original question after a quick scan of the title.
When any government, or any church for that matter, undertakes to say to its subjects, This you may not read, this you
must not see, this you are forbidden to know, the end result is tyranny and oppression no matter how holy the motives.

Robert A. Heinlein

 

TinyPortal © 2005-2018