Revision 38266, 1.2 kB
(checked in by dankogai, 5 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"> 

7  var c1 = cplx(1,2); 

8  var c2 = cplx(3,4); 

9  p(c1); 

10  p(c1.neg()); 

11  p(c1.con()); 

12  p(c1.add(c2)); 

13  p(c1.add(2)); 

14  p(c1.sub(c2)); 

15  p(c1.sub(2)); 

16  p(c1.mul(c2)); 

17  p(c1.mul(2)); 

18  p(c1.div(c2)); 

19  p(c1.div(2)); 

20  p(c1.div(cplx(0,0))); 

21  p(c1.div(0)); 

22  p(c1.arg()); 

23  p(c1.abs()); 

24  p(cplxe(c1.abs(),c1.arg())); 

25  p(c1.exp()); 

26  p(c1.log()); 

27  p(c1.pow(c2)); 

28  p(c1.pow(2)); 

29  p(cplx(2.5).pow(2.5)); 

30  p(c1.eq(c1)); 

31  p(c1.eq(c2)); 

32  p(c1.ne(c1)); 

33  p(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> 

40  rundom = 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  }; 

54  clsdom = function(that){ 

55  that.nextSibling.innerHTML = ''; 

56  }; 

57  </script> 

58  </body> 

59  </html> 
