Programming for Perverts

   Today I was looking at a Sun Certified Java Programmer example test (quite an old one - url no longer valid). There were some quite curious questions. I have taken out and modified questions that apply to C# (unless otherwise noted) and left out Java specific ones. Try to guess the compilation result/output! Here they are in C# version:

1.
     int i = 1;
     i <<= 31;
     i >>= 31;
     Console.WriteLine(i);
2.
     Console.WriteLine(Double.NaN == Double.NaN);

     double zero = 0;
     Console.WriteLine(Double.NaN == 3 / zero);
3.
     int i = 10;
     int j = 10;
     bool b = false;

     if (b = 10 == 10)
         Console.WriteLine("true");
     else
         Console.WriteLine("false");
4. This one behaves differently in Java and C#
Java:
     System.out.println(-0.0);
     System.out.println(-0.0 == +0.0);
     System.out.println(Math.min(-0.0,+0.0));
     System.out.println(Math.max(-0.0,+0.0));
     System.out.println(Math.min(-0.0,+0.0) == Math.max(0.0,+0.0));
C#:
     Console.WriteLine(-0.0);
     Console.WriteLine(-0.0 == +0.0);
     Console.WriteLine(Math.Min(-0.0, +0.0));
     Console.WriteLine(Math.Max(-0.0, +0.0));
     Console.WriteLine(Math.Min(-0.0, +0.0) == Math.Max(0.0, +0.0));
5.
     int i = 0;
     Console.WriteLine(i++ + ++i);
     Console.WriteLine(i++ + i++);
6.
     Console.WriteLine(Double.PositiveInfinity + Double.NegativeInfinity);
     Console.WriteLine(Double.PositiveInfinity == Double.PositiveInfinity);

Check the full article for the actual output!
Posted by:   Stilgar
03:28 16.05.2008

You Can't Stop Rock 'n' Roll (Twisted Sister - Live in Lovech 2008)

You Can't Stop Rock 'n' Roll (Twisted Sister - Live in Lovech 2008)
   This Saturday was not like the others. There was a concert. What is more it was a workday in Bulgaria but even workdays can't stop rock 'n' roll. So we got on my cousin's Alfa Romeo, crossed the Balkan Mountains without getting lost and ended up in Lovech...
Last edited by:   Stilgar
on   12:25 13.05.2008
Posted by:   Stilgar
04:11 12.05.2008

You Can't Stop Rock 'n' Roll (Twisted Sister Ловеч 2008)

You Can't Stop Rock 'n' Roll (Twisted Sister Ловеч 2008)
   Тази събота не беше като другите. Имаше концерт. Освен това беше работен ден, но дори работен ден не може да спре рока. И така братовчед ми подкара Алфа Ромеото, прехвърлихме Стара планина, без да се изгубим и пристигнахме в Ловеч...
Last edited by:   Stilgar
on   12:27 13.05.2008
Posted by:   Stilgar
22:25 11.05.2008

iddqd, idkfa

   Гответе се! DooM се завръща, за да вземе душите ни. Засега няма кой знае каква информация, даже направо никаква няма, но е официално. DooM 4 иде.
Posted by:   Stilgar
01:24 08.05.2008

.NET and SQL Server Adventures

   While preparing the last set of upgrades for the no-blog I stumbled upon some strange issues with different technologies. I reasoned that I might help some of you or some poor googling soul by posting about them here...
Posted by:   Stilgar
03:20 07.05.2008
First Previous ... 51 52 53 54 55 56 57 58 Next Last