Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

floor happily takes an integer arg #2855

Open
infradig opened this issue Mar 21, 2025 · 3 comments
Open

floor happily takes an integer arg #2855

infradig opened this issue Mar 21, 2025 · 3 comments

Comments

@infradig
Copy link

infradig commented Mar 21, 2025

ISO standard section 9.1.1 says

floor/1          floor F -> I

implying anything else as an arg should generate an error. For example consider the definition...

abs/1       abs I, abs F

which takes both.

$ scryer-prolog
?- X is floor(1.2).
X = 1. % CORRECT
?- X is floor(1).
X = 1. % INCORRECT, should throw an error
?- X is abs(1.2).
X = 1.2. % CORRECT
?- X is abs(1).
X = 1. % CORRECT

Various Prologs are a mixed bag on this one.

@infradig infradig changed the title floor takes an integer arg floor happily takes an integer arg Mar 22, 2025
@triska
Copy link
Contributor

triska commented Mar 22, 2025

Same for truncate/1, ceiling/1, round/1, floor/1. I think you @adri326 mentioned before that arithmetic evaluation could be implemented in an overall better way?

@adri326
Copy link
Contributor

adri326 commented Mar 22, 2025

Yeah, I was working on centralizing all three parts relating to it (dispatch, compilation and runtime evaluation) over on https://github.com/adri326/scryer-prolog/tree/arith-rework

That's also what made me find a few issues, as I had written some tests to ensure I didn't break anything

@UWN
Copy link

UWN commented Mar 23, 2025

For the record,

?- X is floor(1).
   type_error(float,1). % Trealla, GNU, Ichiban, ECLiPSe, X
   X = 1, unexpected. % SICStus, (Scryer), SWI, YAP, XSB, B, Ciao, Minerva, IF, IV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants