/tutorial/number/example1.e

http://github.com/tybor/Liberty · Specman e · 57 lines · 42 code · 10 blank · 5 comment · 0 complexity · dbdefdae9201c2d6746daf053d5c4841 MD5 · raw file

  1. class EXAMPLE1
  2. --
  3. -- To start with NUMBERs, just compile and run it :
  4. --
  5. -- compile -o example1 -boost example1
  6. --
  7. insert
  8. ANY
  9. PLATFORM
  10. create {ANY}
  11. make
  12. feature {ANY}
  13. make
  14. local
  15. max, n1, n2: NUMBER
  16. do
  17. max := Maximum_integer.to_number
  18. io.put_string("[
  19. The maximum integer value on this architecture is:
  20. max =
  21. ]")
  22. io.put_number(max)
  23. io.put_string("%N%Nmax + max = ")
  24. io.put_number(max + max)
  25. io.put_string("%Nmax * max = ")
  26. io.put_number(max * max)
  27. io.put_string("%N%Nmax - max * max = ")
  28. io.put_number(max - max * max)
  29. io.put_string("[
  30. Do you like NUMBERs ?
  31. So have a look at NUMBERs division:
  32. ]")
  33. n1 := 2.to_number
  34. n2 := 6.to_number
  35. io.put_string("Assume n1 = ")
  36. io.put_number(n1)
  37. io.put_string(" and n2 = ")
  38. io.put_number(n2)
  39. io.put_string(" then n1/n2 = ")
  40. io.put_number(n1 / n2)
  41. io.put_string("[
  42. With NUMBER, you always get the exact result.
  43. Do you like NUMBERs ?
  44. Have a look at example #2 to know more about NUMBERs
  45. ]")
  46. end
  47. end -- class EXAMPLE1