home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / amigae / e_v3.2a / src / guide / float.e < prev    next >
Text File  |  1977-12-31  |  1KB  |  60 lines

  1. DEF f, i, s[20]:STRING
  2.  
  3. PROC print_float()
  4.   WriteF('\tf is \s\n', RealF(s, !f, 8))
  5. ENDPROC
  6.  
  7. PROC print_both()
  8.   WriteF('\ti is \d, ', i)
  9.   print_float()
  10. ENDPROC
  11.  
  12. /* Square a float */
  13. PROC square_float(f) IS !f*f
  14.  
  15. /* Square an integer */
  16. PROC square_integer(i) IS i*i
  17.  
  18. /* Converts a float to an integer */
  19. PROC convert_to_integer(f) IS Val(RealF(s, !f, 0))
  20.  
  21. /* Converts an integer to a float */
  22. PROC convert_to_float(i) IS RealVal(StringF(s, '\d', i))
  23.  
  24. /* This should be the same as Ftan */
  25. PROC my_tan(f) IS !Fsin(!f)/Fcos(!f)
  26.  
  27. /* This should show float inaccuracies */
  28. PROC inaccurate(f) IS Fexp(Flog(!f))
  29.  
  30. PROC main()
  31.   WriteF('Next 2 lines should be the same\n')
  32.   f:=2.75; i:=!f!
  33.   print_both()
  34.   f:=2.75; i:=convert_to_integer(!f)
  35.   print_both()
  36.  
  37.   WriteF('Next 2 lines should be the same\n')
  38.   i:=10;  f:=i!
  39.   print_both()
  40.   i:=10;  f:=convert_to_float(i)
  41.   print_both()
  42.  
  43.   WriteF('f and i should be the same\n')
  44.   i:=square_integer(i)
  45.   f:=square_float(f)
  46.   print_both()
  47.  
  48.   WriteF('Next 2 lines should be the same\n')
  49.   f:=Ftan(.8)
  50.   print_float()
  51.   f:=my_tan(.8)
  52.   print_float()
  53.  
  54.   WriteF('Next 2 lines should be the same\n')
  55.   f:=.35
  56.   print_float()
  57.   f:=inaccurate(f)
  58.   print_float()
  59. ENDPROC
  60.