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/ceiling/round math builtins should return Int #508

Closed
p6rt opened this issue Dec 19, 2008 · 5 comments
Closed

floor/ceiling/round math builtins should return Int #508

p6rt opened this issue Dec 19, 2008 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 19, 2008

Migrated from rt.perl.org#61526 (status was 'resolved')

Searchable as RT61526$

@p6rt
Copy link
Author

p6rt commented Dec 19, 2008

From @cspencer

The floor/ceiling/round math builtins were returning Num values, causing
statements such as​:

  my Int $x = round(5.4);

to fail with a type mismatch. This patch fixes the above builtins so that
Int values are returned as per S29.

The patch is against src/builtins/math.pir

@p6rt
Copy link
Author

p6rt commented Dec 19, 2008

From @cspencer

math.patch
28,30c28,31
<     .param num a
<     floor a
<     .return (a)
---
>     .param num n
>     .local int i
>     floor i, n
>     .return (i)
44,46c45,48
<     .param num a
<     ceil a
<     .return (a)
---
>     .param num n
>     .local int i
>     ceil i, n
>     .return (i)
61,64c63,67
<     .param num a
<     a += 0.5
<     $N0 = floor a
<     .return ($N0)
---
>     .param num n
>     .local int i
>     n += 0.5
>     floor i, n
>     .return (i)

@p6rt
Copy link
Author

p6rt commented Dec 19, 2008

From @moritz

On Fri Dec 19 08​:35​:04 2008, cspencer wrote​:

The floor/ceiling/round math builtins were returning Num values, causing
statements such as​:

my Int $x = round(5.4);

to fail with a type mismatch. This patch fixes the above builtins so
that
Int values are returned as per S29.

The patch is against src/builtins/math.pir

Thanks, applied as r34116, and added tests to t/spec/S29-num/rounders.t

In future it would be nice if you could generate your patches with 'svn
diff path/to/file', that way they will be easier to apply for me (or if
you do want to use the normal diff, pass the -u option to it).

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Dec 19, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 19, 2008

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Dec 19, 2008
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant