fork(1) download
  1. importPackage(java.io);
  2. importPackage(java.lang);
  3.  
  4. var tests = [0, -5, 42, NaN, "Джигурда", Infinity, -Infinity, true, false, null, [], [42], [42,100500], {}];
  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. }
  15.  
Success #stdin #stdout 0.42s 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
______________x:-5
kegdan code:-1
bormand code:-1
tangled code:-1
another tangled code:-1
3.14159265 code:-1
another bormand code:-1
______________x:42
kegdan code:1
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code:1
______________x:NaN
kegdan code:NaN
bormand code:0
tangled code:NaN
another tangled code:NaN
3.14159265 code:NaN
another bormand code:NaN
______________x:Джигурда
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
______________x:Infinity
kegdan code:NaN
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code:NaN
______________x:-Infinity
kegdan code:NaN
bormand code:-1
tangled code:-1
another tangled code:-1
3.14159265 code:-1
another bormand code:NaN
______________x:true
kegdan code:1
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code:1
______________x:false
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:0
______________x:null
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:0
______________x:
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN
______________x:42
kegdan code:1
bormand code:1
tangled code:1
another tangled code:1
3.14159265 code:1
another bormand code: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
______________x:[object Object]
kegdan code:NaN
bormand code:0
tangled code:0
another tangled code:0
3.14159265 code:0
another bormand code:NaN