root/lang/javascript/math-complex/trunk/complex.html @ 38266

Revision 38266, 1.2 kB (checked in by dankogai, 4 years ago)

division by zero, eq and ne

Line 
1<html>
2<title>Math.Complex</title>
3<script src="complex.js"></script>
4<body>
5<div style="border:outset 1px; padding:0.5em">
6<textarea cols="64" rows="32">
7var c1 = cplx(1,2);
8var c2 = cplx(3,4);
9p(c1);
10p(c1.neg());
11p(c1.con());
12p(c1.add(c2));
13p(c1.add(2));
14p(c1.sub(c2));
15p(c1.sub(2));
16p(c1.mul(c2));
17p(c1.mul(2));
18p(c1.div(c2));
19p(c1.div(2));
20p(c1.div(cplx(0,0)));
21p(c1.div(0));
22p(c1.arg());
23p(c1.abs());
24p(cplxe(c1.abs(),c1.arg()));
25p(c1.exp());
26p(c1.log());
27p(c1.pow(c2));
28p(c1.pow(2));
29p(cplx(-2.5).pow(-2.5));
30p(c1.eq(c1));
31p(c1.eq(c2));
32p(c1.ne(c1));
33p(c1.ne(c2));
34</textarea><br><input type="submit" value="run"   onclick="rundom(this)"
35><input type="submit" value="clear" onclick="clsdom(this)"
36><pre></pre>
37</div>
38
39<script>
40rundom = function(that){
41    try{
42        var out = that.nextSibling.nextSibling;
43        var p = function(s){
44            out.innerHTML += s,
45            out.appendChild(document.createElement('br'));
46        }
47        var e = that.previousSibling.previousSibling;
48        var f = new Function( 'p', (e.value || e.innerText || e.textContent) );
49        f(p);     
50    }catch(e){
51        alert(e);
52    }
53};
54clsdom = function(that){
55  that.nextSibling.innerHTML = '';
56};
57</script>
58</body>
59</html>
Note: See TracBrowser for help on using the browser.