/tutorial/number/example4.e

http://github.com/tybor/Liberty · Specman e · 26 lines · 20 code · 3 blank · 3 comment · 0 complexity · 2b1209dcc679956830ca29b6d8fb3e6f MD5 · raw file

  1. class EXAMPLE4
  2. --
  3. -- Other examples to view NUMBERs.
  4. --
  5. create {ANY}
  6. make
  7. feature {ANY}
  8. make
  9. local
  10. n: NUMBER
  11. do
  12. n := 1.to_number / 5.to_number
  13. io.put_string("(" + n.to_string + ").to_decimal(5,true) -> ")
  14. io.put_string(n.to_decimal(5, True) + "%N")
  15. io.put_string("(" + n.to_string + ").to_decimal(5,false) -> ")
  16. io.put_string(n.to_decimal(5, False) + "%N")
  17. n := 2.to_number / 3.to_number
  18. io.put_string("(" + n.to_string + ").to_decimal(10,true) -> ")
  19. io.put_string(n.to_decimal(10, True) + "%N")
  20. io.put_string("(" + n.to_string + ").to_decimal(10,false) -> ")
  21. io.put_string(n.to_decimal(10, False) + "%N")
  22. end
  23. end -- class EXAMPLE4