- 阅读权限
- 255
- 威望
- 1 级
- 论坛币
- 49635 个
- 通用积分
- 55.7537
- 学术水平
- 370 点
- 热心指数
- 273 点
- 信用等级
- 335 点
- 经验
- 57805 点
- 帖子
- 4005
- 精华
- 21
- 在线时间
- 582 小时
- 注册时间
- 2005-5-8
- 最后登录
- 2023-11-26
|
- Listing 2-3b. A test program for class IntPower.
- Code View: Scroll / Show All
- package numbercruncher.program2_3;
- import numbercruncher.mathutils.IntPower;
- /**
- * PROGRAM 2-3: Test Class IntPower
- *
- * Test the IntPower class.
- */
- public class TestIntPower
- {
- public static .void main(String args[])
- {
- System.out.println(IntPower.raise(2, 5) + " " +
- Math.pow(2, 5));
- System.out.println(IntPower.raise(2, -5) + " " +
- Math.pow(2, -5));
- System.out.println(IntPower.raise(2, 0) + " " +
- Math.pow(2, 0));
- System.out.println(IntPower.raise(2.5, 5) + " " +
- Math.pow(2.5, 5));
- System.out.println();
- System.out.println(IntPower.raise(-2, 5) + " " +
- Math.pow(-2, 5));
- System.out.println(IntPower.raise(-2, -5) + " " +
- Math.pow(-2, -5));
- System.out.println(IntPower.raise(-2, 0) + " " +
- Math.pow(-2, 0));
- System.out.println(IntPower.raise(-2.5, 5) + " " +
- Math.pow(-2.5, 5));
- }
- }
-
复制代码
- Output:
- 32.0 32.0
- 0.03125 0.03125
- 1.0 1.0
- 97.65625 97.65625
- -32.0 -32.0
- -0.03125 -0.03125
- 1.0 1.0
- -97.65625 -97.65625
复制代码
|
|