PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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