DEMO-BCD.PAS 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. Program PrecisionDemo;
  2. {
  3. BCD DEMONSTRATION PROGRAM Version 1.00A
  4. This program demonstrates the increase in precision gained
  5. by using TURBOBCD. Monetary calculations done in floating
  6. point lose precision because there is no precise binary
  7. representation for any power of 1/10 (.1, .01, etc). Binary
  8. coded decimals perform all calculations in decimal and thus
  9. are more precise for financial applications.
  10. INSTRUCTIONS
  11. 1. Compile and run this program using TURBOBCD.COM. Note that
  12. the results are all zero.
  13. 2. Compile and run this program using TURBO.COM and compare
  14. the results with (1) above.
  15. }
  16. Begin
  17. ClrScr;
  18. WriteLn('Each of the following calculations should result in zero provided');
  19. WriteLn('you compiled this program using TURBOBCD.COM:');
  20. Writeln;
  21. WriteLn('(((1234.99 - 1235.0) * 10000.0) + 100.0) * 100000.0 = ',
  22. ((1234.99-1235.0)*10000.0+100.0)*100000.0:1:20);
  23. WriteLn('((1/5) * 5) - 1 = ',
  24. 1/5*5-1:1:20);
  25. WriteLn('1.34 + 1.66 - 3.0 = ',
  26. 1.34+1.66-3.0:1:20);
  27. End.
  28.