How can I perform multiplication without the '*' operator?

前端 未结 30 1531
别跟我提以往
别跟我提以往 2020-12-01 01:47

I was just going through some basic stuff as I am learning C. I came upon a question to multiply a number by 7 without using the * operator. Basically it\'s like this

<
30条回答
  •  Happy的楠姐
    2020-12-01 02:35

    Another thinking-outside-the-box answer:

    BigDecimal a = new BigDecimal(123);
    BigDecimal b = new BigDecimal(2);
    BigDecimal result = a.multiply(b);
    System.out.println(result.intValue());
    

提交回复
热议问题