Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement float is_integer method #112
Conversation
|
In Go: 1.9.x, there is no math.Round method
|
|
we could drop support for |
|
please rebase on top of the latest |
codecov-io
commented
Oct 2, 2019
•
Codecov Report
@@ Coverage Diff @@
## master #112 +/- ##
==========================================
+ Coverage 72.54% 72.61% +0.06%
==========================================
Files 60 60
Lines 11887 11895 +8
==========================================
+ Hits 8623 8637 +14
+ Misses 2739 2731 -8
- Partials 525 527 +2
Continue to review full report at Codecov.
|
| return nil, err | ||
| } | ||
| b := math.Abs(f - math.Round(f)) | ||
| return NewBool(b < math.SmallestNonzeroFloat64), nil; |
This comment has been minimized.
This comment has been minimized.
corona10
Oct 3, 2019
•
Member
Is there any reason to use this logic?
CPython check the float is an integer by using the floor API.
o = (floor(x) == x) ? Py_True : Py_False;
This comment has been minimized.
This comment has been minimized.
DoDaek
Oct 3, 2019
•
Author
Contributor
Calculating the difference between rounded value and original value.
If the difference is less than the minimum value of float64, I think that it would be an integer.
I'll check the Cpython and then fix that part by using floor API.
This comment has been minimized.
This comment has been minimized.
| b := math.Abs(f - math.Round(f)) | ||
| return NewBool(b < math.SmallestNonzeroFloat64), nil; | ||
| } | ||
| return nil, AttributeError |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| f, err := FloatAsFloat64(a) | ||
| if err != nil { | ||
| return nil, err | ||
| f, _ := FloatAsFloat64(a) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| } | ||
| return nil, AttributeError | ||
| _, e := cantConvert(self, "float") |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
DoDaek
Oct 4, 2019
Author
Contributor
How do I use the second return value directly?
Sorry, I'm looking for that. But I can't find any information.
| } | ||
| return False, nil | ||
| } | ||
| _, e := cantConvert(self, "float") |
This comment has been minimized.
This comment has been minimized.
sbinet
Oct 4, 2019
Member
| _, e := cantConvert(self, "float") | |
| return cantConvert(self, "float") |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
LGTM |


DoDaek commentedOct 2, 2019
ISSUE : #111