home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / pascal / 4843 < prev    next >
Encoding:
Text File  |  1992-08-13  |  1.6 KB  |  47 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!cleveland.Freenet.Edu!bj198
  3. From: bj198@cleveland.Freenet.Edu (Jeremy Mans)
  4. Subject: Re: Rounding real #s
  5. Message-ID: <1992Aug13.221937.13744@usenet.ins.cwru.edu>
  6. Sender: news@usenet.ins.cwru.edu
  7. Nntp-Posting-Host: slc8.ins.cwru.edu
  8. Reply-To: bj198@cleveland.Freenet.Edu (Jeremy Mans)
  9. Organization: Case Western Reserve University, Cleveland, OH (USA)
  10. References: <1992Aug12.134112.4397@crpmks.uucp> <164i0vINN2lo@tony.ksu.ksu.edu> <1992Aug11.082014.26260@qiclab.scn.rain.com>
  11. Date: Thu, 13 Aug 92 22:19:37 GMT
  12. Lines:       34
  13.  
  14.  
  15. In a previous article, billb@crpmks.uucp (Bill Bochnik Info Systems)) says:
  16.  
  17. >In article <1992Aug11.082014.26260@qiclab.scn.rain.com> 70465.203@compuserve.com writes:
  18. >>wmorgan@tony.ksu.ksu.edu () writes:
  19. >>
  20. >>>    I am a new user of TP 6.0, and would like to know how to round a
  21. >>>real number to 2 decimal places, I.E. round 456.2345 to 456.23.  I am working
  22. >>>on a payroll program.
  23. >>
  24. >>in a Write, or writeln, you just tack :x:y onto the variable. eg
  25. >>    write(pay:6:2)
  26. >>will print the contents of pay as a 6 place number with two places to the
  27. >>left of the decimal.
  28. >>-123.45
  29. >> 123.45
  30.  
  31.     OR try this:
  32.  
  33.   pay:=Round(Pay*100.0)/100.0;
  34.  
  35.   Note - this is for all numbers, providing of course that you don't
  36. exceed MaxReal    (which by the way is 1.7 x 10^38.......)
  37.  
  38.  
  39.             -jmans 
  40.  
  41.  
  42. -- 
  43. Jeremy Mans     |FORTRAN II - A Model T Ford. Once it was king of the
  44. bj198@cleveland.|                       road    
  45.    freenet.edu  |FORTRAN IV - A Model A Ford    
  46. Omaha, NE (CU)  |FORTRAN 77 - A V6 Ford Fairlane, no seat belts, auto
  47.