Strange things happens when I use Long... Try this and correct me if I am wrong.


  • 0
    V

    {
    class Solution{

    public static void main(String[] args){
    Solution s = new Solution();
    System.out.println(s.multiply("93553535314", "25247452591474"));
    System.out.println(s.multiply("14", "4"));
    Long a = 3553535314L;
    Long b = 7452591474L;
    System.out.println(a.toString() + " * " + b.toString() + "=" + a*b);

    }
    

    }
    }

    The problem is that: a= 3553535314, b = 7452591474, a*b should be 26483046983674312836L,

    but Java give me: a * b =8036302909964761220........

    This cost me 30 mins to find and finally corrected it by going around.... Why ?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.