fork(2) download
  1. importPackage(java.io);
  2. importPackage(java.lang);
  3.  
  4. var tests = [0, -5, 42, NaN, "Джигурда", Infinity, -Infinity, null, [], {}, [42], [42, 100500], [-42], [0], ['5'], ['-42'], ['0'], true, false, undefined];
  5. for (var i=0; i<tests.length; i++) {
  6. var x = tests[i];
  7. System.out.println("______________x:"+x);
  8. System.out.println("kegdan code:"+ (x === 0 ? 0 : x / Math.abs(x)));
  9. System.out.println("bormand code:"+ (x < 0 ? -1 : x > 0 ? 1 : 0) );
  10. System.out.println("tangled code:"+ (x!=x ? x : (x>0)-(x<0)));
  11. System.out.println("another tangled code:"+ (((x>0)-(x<0))/(x==x)) );
  12. System.out.println("3.14159265 code:"+ ((x==x) ? (x>0)-(x<0) : x));
  13. System.out.println("another bormand code:"+ (x+(x>0)-(0>x)-x));
  14. System.out.println("fatality:"+ (typeof(x) != 'number' || isNaN(x) ? NaN : (x>0)-(0>x)));
  15. }
  16.  
Success #stdin #stdout 0.45s 381888KB
stdin
Standard input is empty
stdout
______________x:0
kegdan code:0
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:0
fatality:0
______________x:-5
kegdan code:-1
bormand code:-1
tangled code:-1
another tangled code:-1
3.14159265 code:-1
another bormand code:-1
fatality:-1
______________x:42
kegdan code:1
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code:1
fatality:1
______________x:NaN
kegdan code:NaN
bormand code:0
tangled code:NaN
another tangled code:NaN
3.14159265 code:NaN
another bormand code:NaN
fatality:NaN
______________x:Джигурда
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
fatality:NaN
______________x:Infinity
kegdan code:NaN
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code:NaN
fatality:1
______________x:-Infinity
kegdan code:NaN
bormand code:-1
tangled code:-1
another tangled code:-1
3.14159265 code:-1
another bormand code:NaN
fatality:-1
______________x:null
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:0
fatality:NaN
______________x:
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
fatality:NaN
______________x:[object Object]
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
fatality:NaN
______________x:42
kegdan code:1
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code:NaN
fatality:NaN
______________x:42,100500
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
fatality:NaN
______________x:-42
kegdan code:-1
bormand code:-1
tangled code:-1
another tangled code:-1
3.14159265 code:-1
another bormand code:NaN
fatality:NaN
______________x:0
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
fatality:NaN
______________x:5
kegdan code:1
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code:NaN
fatality:NaN
______________x:-42
kegdan code:-1
bormand code:-1
tangled code:-1
another tangled code:-1
3.14159265 code:-1
another bormand code:NaN
fatality:NaN
______________x:0
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
fatality:NaN
______________x:true
kegdan code:1
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code:1
fatality:NaN
______________x:false
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:0
fatality:NaN
______________x:undefined
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
fatality:NaN