All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.roguewave.examples.money.currency.v1_0.Example1

java.lang.Object
   |
   +----com.roguewave.examples.money.currency.v1_0.Example1

public class Example1
extends Object
A very simple example illustrating how decimals give exact results, where the primitives double or float have built-in rounding errors.

Author:
Trevor Misfeldt

Constructor Index

 o Example1()

Method Index

 o main(String[])
Run program by using this command.
 o usingDecimal()
 o usingDecimalFromDouble()
 o usingDouble()

Constructors

 o Example1
 public Example1()

Methods

 o main
 public static void main(String args[])
Run program by using this command.

java com.roguewave.examples.money.currency.v1_0.Example1

Output should appear as follows:

 using BigDecimal...
 account balance: 0.00
 balances
 using double...
 account balance: 6.661338147750939E-16
 does not balance
 using BigDecimal from double...
 account balance: 0.00000000000000002081668171172168513294309377670288085937500
 does not balance
 

 o usingDecimal
 protected static void usingDecimal()
 o usingDouble
 protected static void usingDouble()
 o usingDecimalFromDouble
 protected static void usingDecimalFromDouble()

All Packages  Class Hierarchy  This Package  Previous  Next  Index