The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Rather cold in here...

Last post 11-19-2008 11:38 AM by Fred Foobar. 23 replies.
Page 1 of 1 (24 items)
Sort Posts: Previous Next
  • 10-28-2008 2:24 PM

    • Vechni
    • Top 500 Contributor
    • Joined on 09-12-2007
    • Baltimore, MD
    • Posts 124

    Rather cold in here...

    So, I'll show this simple code I use, but if someone else were to find it, they would definetly see a WTF....

    public class Heater
    {
      public static void main(String[ args)
      {
        new Heater();
      }

      public Heater()
      {
      int i = 1;
        while (true)
        {
          i = i * 2 - 50;
        }
      }
    }

     

    I run this code once a day because it's a tad chilly in my cubicle. Don't really plan on spending the money on a space heater. Recently moved north and haven't bought much winter clothes yet.

  • 10-28-2008 4:08 PM In reply to

    Re: Rather cold in here...

    Um... yeah... well, if you're counting on that to overheat your chips to defrost your frostbitten appendages, you'd better be running on some very cheap equipment with no heat sink, because that will overflow and throw an out of range exception fairly quickly I think.

    And yeah... what morbius said.
    - Dan
  • 10-28-2008 4:16 PM In reply to

    Re: Rather cold in here...

     This isn't even funny in an ironic sense.

  • 10-28-2008 8:33 PM In reply to

    Re: Rather cold in here...

    Aaron:

     This isn't even funny in an ironic sense.

     

    Maybe it's funny in that it's not funny at all.

  • 10-28-2008 10:12 PM In reply to

    Re: Rather cold in here...

    BlueKnot:
    Um... yeah... well, if you're counting on that to overheat your chips to defrost your frostbitten appendages, you'd better be running on some very cheap equipment with no heat sink, because that will overflow and throw an out of range exception fairly quickly I think.

    You'll find .NET has a liberal definition of overflowing.

    Here's the result of multiplying -100 by 1000 constantly:

    -100000
     -100000000
     -1215752192
     -276447232
     -1569325056
     -1661992960
     159383552
     469762048
     1610612736
     0

    After there it gets predictable :P I'm sure if you were to look at the binary you'd be able to find out why that overflow happened, but yeah there's no error for breaking the integer barrier in .NET, just nonsense output.

    EDIT: Figured I'd give you the code just to make it obvious what I did, as primitive as it is.

                int i = -100;
                while (true)
                {
                    i *= 1000;
                    Console.WriteLine(i);
                    Console.ReadKey(); // So that I can kill it once I get my proof

               }

  • 10-29-2008 4:33 AM In reply to

    Re: Rather cold in here...

    Not that it really matters, but it's Java. And morbiuswilters is right.

  • 10-29-2008 4:49 AM In reply to

    Re: Rather cold in here...

     

    Vechni:

    public Heater()
    {
      int i = 1;
      while (true)
      {
        i = i * 2 - 50;
      }
    }
    

    Wouldn't the compiler optimize this part away? I don't know Java well enough but in C++ pieces of code that have no effect don't end up in the release version unless (in this particular case) you declare int i as volatile...

    ...and what Morbs said

    Our chief weapon is suprise. Fear and surprise!
  • 10-29-2008 5:50 AM In reply to

    • ZPedro
    • Not Ranked
    • Joined on 06-24-2008
    • Posts 6

    Re: Rather cold in here...

    You know, in defense of the OP, sometimes when I look at some PSU capabilities, and some video cards consumption, I think I'm looking the specs for an electric heater and not computing equipment.

     

    public class Heater
    {
      public static void main(String[ args)
      {
        new Heater();
      }

      public Heater()
      {
      int i = 1;
        while (true)
        {
          i = i * 2 - 50;
        }
      }
    }

    Pah! Real programmers would put enough instruction-level parallelism to saturate the execution units of the processor, including putting floating-point, integer, and vector calculations. They would also spawn enough threads to occupy all cores of the machine (granted, that can be done by spawning multiple copies of the program above). Real elite programmers would also code a version in CUDA (or whatever GPU general-purpose programming language that matches the GPU they have) to also take advantage of the heat generation capabilities of their video hardware.

  • 10-29-2008 6:44 AM In reply to

    • Zemm
    • Top 500 Contributor
    • Joined on 11-26-2007
    • Gold Coast, Australia
    • Posts 125

    Re: Rather cold in here...

    ZPedro:
    You know, in defense of the OP, sometimes when I look at some PSU capabilities, and some video cards consumption, I think I'm looking the specs for an electric heater and not computing equipment.
     

    I am yet to find a 2400W PSU: my portable heater is 2400W. But then we are going into summer now! The beach was great today.

  • 10-29-2008 7:53 AM In reply to

    Re: Rather cold in here...

    ZPedro:
    Real elite programmers would also code a version in CUDA (or whatever GPU general-purpose programming language that matches the GPU they have) to also take advantage of the heat generation capabilities of their video hardware.
    Yeah, but most of them are dangerously insane too.

    SpectateSwamp: I can see you. You don't have to hide anymore. C'mon out and play!
  • 10-29-2008 9:27 AM In reply to

    Re: Rather cold in here...

    My gaming rig with its three GTX 280s makes a wonderful space heater. That part of my home is about 5-10 degrees warmer than anywhere else. It's also near to a plasma TV which puts out a good deal of heat as well... Playing Far Cry 2 for example brings the GPUs up to about 85° C, and that just gets pumped right out the back. I need to go pick up some water blocks for those cards... My CPU runs at a cool 35° C at full load thanks to that.
  • 10-29-2008 10:22 AM In reply to

    • Vechni
    • Top 500 Contributor
    • Joined on 09-12-2007
    • Baltimore, MD
    • Posts 124

    Re: Rather cold in here...

    BlueKnot:
    Um... yeah... well, if you're counting on that to overheat your chips to defrost your frostbitten appendages, you'd better be running on some very cheap equipment with no heat sink, because that will overflow and throw an out of range exception fairly quickly I think.

    And yeah... what morbius said.
     

    I would prefer a heatsink....as It would pull heat off of the CPU and disperse it into the air, as opposed to letting disapate from the CPU and onto my desk. And ofc, other reasons.

    It works pretty well, CPU hits 50%, derrr it's running on 1 core... So, run another instance and it's 100% (you could say that it has a high and low setting).... I have a laptop so I just turn it so that the exhaust fan points to myself and It is rather comfortable.....

    What did morbs say...? Was his post deleted or something because I don't see it.......

  • 10-29-2008 10:50 AM In reply to

    Re: Rather cold in here...

    Vechni:
    What did morbs say...? Was his post deleted or something because I don't see it.......

    Yes.  I told the OP that he was TRWTF.  Some stupid hippie moderator deleted it because it didn't contribute to the Love-In or whatever. 

    < pstorer> Bans don't mean shit on the forum. It's like being on the Sex Offender List. You can still entice kids into your van with candy.

    Want more? Go the IRC channel #TDWTFMafia on irc.slashnet.org.
  • 10-29-2008 11:43 AM In reply to

    • Vechni
    • Top 500 Contributor
    • Joined on 09-12-2007
    • Baltimore, MD
    • Posts 124

    Re: Rather cold in here...

    morbiuswilters:

    Vechni:
    What did morbs say...? Was his post deleted or something because I don't see it.......

    Yes.  I told the OP that he was TRWTF.  Some stupid hippie moderator deleted it because it didn't contribute to the Love-In or whatever. 

     

     

    I don't see the logic in deleting that.

    1) I can't refute his opinion if it is deleted, nor read it for that matter but others can...? If he has an opinion it should be open to discussion for everyone.

    2) I don't care it's just a forum....?

     

    Can you repost...? hopefully the mod won't delete it this time............. This wasn't the case a year ago

  • 10-29-2008 1:34 PM In reply to

    • nion
    • Not Ranked
    • Joined on 10-13-2008
    • Glen Burnie, MD
    • Posts 16

    Re: Rather cold in here...

     TRWTF is the OP.

    I play music.
    http://myspace.com/abreakinchaos
  • 10-29-2008 3:13 PM In reply to

    Re: Rather cold in here...

    fyjham:

    BlueKnot:
    Um... yeah... well, if you're counting on that to overheat your chips to defrost your frostbitten appendages, you'd better be running on some very cheap equipment with no heat sink, because that will overflow and throw an out of range exception fairly quickly I think.

    You'll find .NET has a liberal definition of overflowing.

    Here's the result of multiplying -100 by 1000 constantly:

    -100000
     -100000000
     -1215752192
     -276447232
     -1569325056
     -1661992960
     159383552
     469762048
     1610612736
     0

    After there it gets predictable :P I'm sure if you were to look at the binary you'd be able to find out why that overflow happened, but yeah there's no error for breaking the integer barrier in .NET, just nonsense output.

    EDIT: Figured I'd give you the code just to make it obvious what I did, as primitive as it is.

                int i = -100;
                while (true)
                {
                    i *= 1000;
                    Console.WriteLine(i);
                    Console.ReadKey(); // So that I can kill it once I get my proof

               }

    Just use (checked) before the operation that might overflow. As in

    int i = 0;
    (checked)i++;

    This way it'll raise an exception if it overflows. Yeah I was impressed by how .NET allows overflows to happen without a warning, but I think it's just a minor WTF as there's documentation covering that.
    nion:

    TRWTF is the OP.

    Indeed.
    snoofle

    That hideousness is what keeps you and I employed!
  • 10-29-2008 3:13 PM In reply to

    Re: Rather cold in here...

     It's obvious TRWTF is that "String [args" needs a closing bracket.

  • 10-30-2008 6:04 AM In reply to

    Re: Rather cold in here...

    Vechni:

    I run this code once a day because it's a tad chilly in my cubicle. Don't really plan on spending the money on a space heater. Recently moved north and haven't bought much winter clothes yet.

    Amateur!

    # cat spaceheater.sh
    #!/bin/bash
    
    cd /usr/src/linux
    while true; do make -j32 bzImage; make clean; done
    

    Also a handy memory tester, and a handy way to make a RAID5 array sound like a damaged Klingon battle cruiser.

    When sucking up to IT gets even dumber than usual:
    <DriveThruGuy> Welcome to Wendy's. May I take your order?
    <MyStupidBoss> I can haz cheezburger?
  • 10-30-2008 8:11 AM In reply to

    Re: Rather cold in here...

    Vechni:

    So, I'll show this simple code I use, but if someone else were to find it, they would definetly see a WTF....

    public class Heater
    {
      public static void main(String[ args)
      {
        new Heater();
      }

      public Heater()
      {
      int i = 1;
        while (true)
        {
          i = i * 2 - 50;
        }
      }
    }

     

    I run this code once a day because it's a tad chilly in my cubicle. Don't really plan on spending the money on a space heater. Recently moved north and haven't bought much winter clothes yet.

     

    Eat more beans.

  • 10-30-2008 8:36 AM In reply to

    Re: Rather cold in here...

    cklam:

    Eat more beans.

    Don't forget to give him a lighter. No sense wasting perfectly flammable methane.
    When sucking up to IT gets even dumber than usual:
    <DriveThruGuy> Welcome to Wendy's. May I take your order?
    <MyStupidBoss> I can haz cheezburger?
  • 10-30-2008 1:16 PM In reply to

    • dtech
    • Top 50 Contributor
    • Joined on 11-13-2007
    • Utrecht, Netherlands
    • Posts 424

    Re: Rather cold in here...

    Renan "C#" Sousa:
    Yeah I was impressed by how .NET allows overflows to happen without a warning, but I think it's just a minor WTF as there's documentation covering that.
     

    Java does it too, unlike morbius said. Does anyone know mainstream stong-typed languages that don't allow it? (genuine question)

    > Executing: C:\Program Files (x86)\ConTEXT\ConExec.exe "C:\Program Files\Java\jdk1.6.0_07\bin\java.exe" OverflowTest
    0         1
    1         10000
    2         100000000
    3         -727379968
    4         1874919424
    5         1661992960
    6         -1593835520
    7         268435456
    8         0
    9         0
    > Execution finished.
    class OverflowTest
    {
        public static void main(String[ args)
        {
    		int a = 1;
    
    		for(int i=0; i < 10;i++)
    		{
    			System.out.println(i + "\t " + a);
                a *= 10000;
            }
        }
    }
  • 10-30-2008 2:37 PM In reply to

    Re: Rather cold in here...

    dtech:

    Java does it too, unlike morbius said. Does anyone know mainstream stong-typed languages that don't allow it? (genuine question)

    VB has checking on by default. (genuine answer)
    
    Public Module Test
      Sub Main()
        Dim i as Integer = 1
        Do
          i *= 10000
        Loop
      End Sub
    End Module
    
    ╩юфют√ь ёЄЁрэшЎрь яюЁр эр яхэёш■.

    Visit #TDWTF @ SlashNET - the semi-official WTF IRC channel.
  • 11-19-2008 10:39 AM In reply to

    • Lamah
    • Not Ranked
    • Joined on 11-20-2005
    • Posts 5

    Re: Rather cold in here...

    Delphi has range and overflow checking modes for the program, but I don't think that they're on by default (they're certainly on in all of my projects!)

  • 11-19-2008 11:38 AM In reply to

    Re: Rather cold in here...

    In before lock.
    The TDWTF Drinking Algorithm
    while (numDrinks < 3) {
    haveADrink();
    }
    gotoWork();
    while (numDrinks < 6) {
    haveADrink();
    }
    wasteMyTimeAndOthersOnTDWTF();
Page 1 of 1 (24 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems