-
Notifications
You must be signed in to change notification settings - Fork 825
Improve compatibility to CRuby for Float#to_s
#4225
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
Improve compatibility to CRuby for Float#to_s
#4225
Conversation
Bfore: Float::INFINITY.to_s #=> "inf" 50.0.to_s #=> "50" 1e20.to_s #=> "1e+20" After / CRuby: Float::INFINITY.to_s #=> "Infinity" 50.0.to_s #=> "50.0" 1e20.to_s #=> "1.0e+20"
For conforming C standard.
|
Not a revert request but we should be careful that mruby promotes overflowed integer since mruby doesn't have |
|
OK, I will revert part of this PR. |
Since in mruby, Integer and Float interchange frequently (mostly on overflow), so adding explicit `.0` can cause problems sometimes. For example: mattn/mruby-json#40 pepabo/mruby-msd#13 mattn/mruby-json#42
|
So I removed explicit |
|
LGTM now |
|
Thank you. |
|
Is it okay in the case of exponential notation? (e.g. |
|
I think so. The only reason I tried to remove the trailing |
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test. ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ```
…ruby-for-float-to_s Improve compatibility to CRuby for `Float#to_s`
Bfore:
After / CRuby: