-
Notifications
You must be signed in to change notification settings - Fork 171
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
[WIP] Adding VM Float API #615
Conversation
Codecov Report
@@ Coverage Diff @@
## master #615 +/- ##
==========================================
- Coverage 82.94% 82.88% -0.07%
==========================================
Files 56 56
Lines 7501 7544 +43
==========================================
+ Hits 6222 6253 +31
- Misses 1027 1033 +6
- Partials 252 258 +6
Continue to review full report at Codecov.
|
@SD10 for test cases, can you include Ruby doc's examples? Like https://ruby-doc.org/core-2.4.0/Float.html#method-i-ceil |
I'm implementing @st0012 How do you think we should implement these constants? We also need |
I had a look at the IEEE754 specification, the MRI source code, and the Golang API, and there are a few interesting points:
To summarize, based on my understanding, I think that:
|
@saveriomiroddi Thanks for writing that up. I totally overlooked that we can still implement those methods. |
@saveriomiraddi thanks for the information, learned a lot 🙇♂️ |
a = Float::NAN
return a != a NAN is the only float value for which this will be true. |
@SD10 Is it ok if I take over this PR? |
Hey everyone 👋,
I started working on #484. However, I'm new to Goby, Go, and Ruby 😂
This is classified as work in progress because I wanted to make sure I'm doing things correctly before trying to implement the full API. Any feedback is appreciated!
Referenced from the Ruby Ver. 2.4.1. Float data type API:
Constant
Float::INFINITE
stands for the number is infiniteFloat#abs
Return positive number of the float. "Formally as the distance between 0 to the number of the float in 1-dimensional axis ..."Float#angle
(andFloat#arg
) If positive -> return 0; else -> return PIFloat#ceil
Returns smallest number greater than or equal to the receiverFloat#floor
Returns largest number smaller than or equal to the receiverFloat#round
Rounds float to a given precision in decimal digits (default 0 digits). Precision may be negative. Returns a floating point number whenn
digits is more than zero.Float#finite?
Returnstrue
if receiver isn't equal toFloat::INFINITE
Float#infinite?
Returnstrue
if receiver is equal toFloat::INFINITE
Float#divmod
Returns array which is in format of [ (Integer) Quotient, (Float) Remainder ]Float#positive?
Returnstrue
if float number is larger than0.0
Float#negative?
Returnstrue
if float number is less than0.0
Float#zero?
Returnstrue
if float number is equal to0.0
Lower priority:
Float::NAN
stands for "Not a Number"Float#nan?
Returnstrue
if receiver is equal toFloat::NAN
Float#rationalize
Convert to something calledRational
data type (Currently not supported but from my point of view, it is worth being addressed in this issue)This closes #484