Advertisement
Guest User

Reduction

a guest
Jan 20th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. void Measure::simplify()
  2. {
  3. // make the amount bigger if it is less than 1, unless the unit is already
  4. //"dram" (in which case the amount can't be made any bigger).
  5. Measure temp;
  6. while (unit!=0 && amount < 1) {
  7. temp.amount = conversionTable[unit - 1];
  8. amount = amount *temp.amount;
  9. unit--;
  10. }
  11. //make the amount smaller if it can be made smaller without making it
  12. //less than 1, unless the unit is already acre_ft (in which case the
  13. //amount can't be made any smaller)
  14. while (unit!=11 && amount > 1 ) {
  15.  
  16. temp.amount = conversionTable[unit];
  17. amount *= (1 / temp.amount);
  18. unit++;
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement