Beta

toHonestlyFixed()

Description
Loading description...
Refactoring
  • Please sign in or sign up to leave a comment.
  • Blind4Basics Avatar
    • 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:

      [Number: 677253.527192] 8
      Should work with random numbers between 0.0000001 and 9999999.9999999 
      Expected: '677253.52719199', instead got: '677253.52719200'
      
  • Voile Avatar

    The tests does not check if the thing thrown is actually according to the descriptions.

  • GiacomoSorbi Avatar

    Ruby and Python translations submitted if you wish to approve them!

  • danield21 Avatar

    When the number is negative, the test is asking to round up, not down.

    -3000.567 rounded down is -3000.6, not -3000.5

  • e.mihaylin Avatar

    This comment has been hidden.

  • msachi Avatar

    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!

    • njsfield Avatar

      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 :)

    • msachi Avatar

      Welcome - yup much clearer now :)

  • smile67 Avatar

    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

    • njsfield Avatar

      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!

      Issue marked resolved by njsfield 9 years ago
    • smile67 Avatar

      Ok, thanks! You marked it as resolved, so everything is ok;-)!