Skip to content

Conversation

@ksss
Copy link
Contributor

@ksss ksss commented Mar 21, 2014

Current is like that.

> inf = 1.0/0.0
 => inf
> inf.round
 => -2147483648
> inf.round(-1)
 => -2147483648
> inf.round(1)
 => inf
> nan = 0.0/0.0
 => NaN
> nan.round
 => -2147483648
> nan.round(-1)
 => -2147483648
> nan.round(1)
 => NaN
> 42.0.round(306)
 => 42.0
> 42.0.round(307)
 => inf
> 1.0e307.round(1)
 => 1.0e+307
> 1.0e307.round(2)
 => inf

I think it's should be like that.

> inf = 1.0/0.0
 => inf
> inf.round
(mirb):1: Infinity (FloatDomainError)
> inf.round(-1)
(mirb):1: Infinity (FloatDomainError)
> inf.round(1)
 => inf
> nan = 0.0/0.0
 => NaN
> nan.round
(mirb):1: NaN (FloatDomainError)
> nan.round(-1)
(mirb):1: NaN (FloatDomainError)
> nan.round(1)
 => NaN
> 42.0.round(306)
 => 42.0
> 42.0.round(307)
 => 42.0
> 1.0e307.round(1)
 => 1.0e+307
> 1.0e307.round(2)
 => 1.0e+307

matz added a commit that referenced this pull request Mar 22, 2014
Float#round fix bug for infinity and nan cases
@matz matz merged commit 5488da6 into mruby:master Mar 22, 2014
@akuroda
Copy link
Contributor

akuroda commented Mar 22, 2014

@ksss
Copy link
Contributor Author

ksss commented Mar 22, 2014

👍

@ksss ksss deleted the float-round branch March 22, 2014 12:34
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

Successfully merging this pull request may close these issues.

3 participants