Beta
toHonestlyFixed()
40njsfield
Loading description...
Refactoring
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
tests should be updated to node 12
not enough random tests
errors should be included in the random scenarii
the ref solution is incorrect, because subject to floating point errors:
The tests does not check if the thing thrown is actually according to the descriptions.
Ruby and Python translations submitted if you wish to approve them!
When the number is negative, the test is asking to round up, not down.
-3000.567 rounded down is -3000.6, not -3000.5
This comment has been hidden.
This comment has been hidden.
Looks good, just one note: I think your
num
notation is confusing. In the kata description it refers to the number being tested, whereas in the code template it refers to the number of digits that the number should be fixed to. Call it something else!Thanks for the feedback! Completely overlooked the potential confusion there- I've changed the template code to use 'digits' instead of 'num' to ensure it's meaning is seperate from the actual number passed in :)
Welcome - yup much clearer now :)
Hi, i think your random testcases are not correct. One example: 202786537.41127864 (this) 8 (num) Should work with random numbers between 0.000000001 and 999999999.999999999 - Expected: 202786537.41127863, instead got: 202786537.41127864
Part of the problem was my test case function was using toString which didn't behave as expected for numbers 18-19 digits in length. I've edited and republished to include your solution for the test cases, to ensure accuracy, great solution btw!
Ok, thanks! You marked it as resolved, so everything is ok;-)!