5 kyu

isInt32(int, byteLength)

122 of 123wthit56
Description
Loading description...
Bits
Fundamentals
  • Please sign in or sign up to leave a comment.
  • eyutekle Avatar

    How is int(10) and bit length = 5 Test Case expected to be False, Ten in binary is 1010 and the bitlength from the Least significant bit to Most significant bit is 5 , so there is no value after . The test Case should flag True.

  • FArekkusu Avatar

    byteLength should be renamed; "byte" != "bit", and they should not be mixed.

  • FArekkusu Avatar

    Input validation is not properly explained. Missing information about handling null and undefined length.

  • ofirmgr Avatar

    unclear case

  • Voile Avatar

    Seriously needs example test cases. It's entirely far from obvious from the real test cases what's expected and why something is wrong, and it doesn't help that the test case size is so big every time I submit my code my browser chokes for like dozens of seconds.

  • philipwatson Avatar

    Hi there.

    Your test code never tests the boundary condition where byteLength = 32 and int is a negative number.

    i.e., isInt32(-448, 32)

    Because of this my first solution is so wrong :-(

    Adding something like test(-5, 32); to your test cases will be cool. And perhaps test(5, 0); and test(-5, 0) also.

    And may be change Math.random() * 32 | 0 to Math.random * 33 | 0 so there is a chance of hitting 32 (since there is already a chance of hitting the other boundary, 0)

    Awesome kata btw.

  • DaveAlger Avatar

    It seems that according to the tests run that giving a decimal value that is equal to an integer (e.g. 10.0) returning true is ok. Is that what is intended?

  • user7973646 Avatar

    When I test my code in labs.codecademy I get the value that is expected. When I submit it on codewars I get the value that isn't expected. What could be causing this? It's the same code and I use the same test example values.

  • kirilloid Avatar

    Having null as default doesn't correspond to es6 semantics.

  • warning Avatar

    This comment has been hidden.

  • jacobb Avatar

    This comment has been hidden.

  • jacobb Avatar

    Before starting, I would recommend right-to-left be aka most significant bit to least significant bit.

    Edit: I mean least significant to most significant?

  • joeycozza Avatar

    This comment has been hidden.

  • joeycozza Avatar

    This comment has been hidden.

  • joeycozza Avatar

    This comment has been hidden.