Ad
  • Default User Avatar

    make sure your types can fit your values

    your rounding error probably comes from involving f64, python:

    >>> int(float(9**19))
    1350851717672992000
    

    likewise, make sure you use a large enough integer type - for example, 1350851717672992000 barely fits in a 64-bit int but not in a 32-bit int, and if you were to go a bit bigger than that you would overflow the 64-bit int as well

  • Default User Avatar

    Have you resolved it? I have the same problem

  • Default User Avatar

    I'm stuck on this with Swift. My code passes all tests except for very large numbers apparently:

    Full Tests
    XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 35875699062250035
    XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 4498128791164624869
    XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 4929273885928088826
    XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 21897142587612075
    XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 1517841543307505039
    XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 35641594208964132
    XCTAssertEqual failed: ("true") is not equal to ("false") - Should return true for 3289582984443187032

    When I logged my output I saw that I have rounding errors, for example:
    9 ^ 19 = 1350851717672992089

    But Swift returns 1350851717672992000

    Has anyone had the same problem? Any tips?