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.



  • 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.



  •  This isn't even funny in an ironic sense.



  • @Aaron said:

     This isn't even funny in an ironic sense.

     

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



  • @BlueKnot said:

    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

               }



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


  • :belt_onion:

     @Vechni said:

    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



  • 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.

     

    [font=Monaco,'Courier New',monospace][size=10pt]public class Heater
    {
      public static void main(String[ args)
      {
        new Heater();
      }

      public Heater()
      {
      int i = 1;
        while (true)
        {
          i = i * 2 - 50;
        }
      }
    }[/size][/font]

    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.



  • @ZPedro said:

    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.



  • @ZPedro said:

    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.



  • 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.



  • @BlueKnot said:

    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.......



  • @Vechni said:

    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. 



  • @morbiuswilters said:

    @Vechni said:

    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



  •  TRWTF is the OP.



  • @fyjham said:

    @BlueKnot said:

    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 said:

    TRWTF is the OP.

    Indeed.



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



  • @Vechni said:

    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.



  • @Vechni said:

    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.



  • @cklam said:

    Eat more beans.

    Don't forget to give him a lighter. No sense wasting perfectly flammable methane.



  • [quote user="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.[/quote] 

    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;
        }
    }
    

    }



  • @dtech said:

    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)

    [code]
    Public Module Test
      Sub Main()
        Dim i as Integer = 1
        Do
          i *= 10000
        Loop
      End Sub
    End Module
    [/code]


  • 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!)



  • In before lock.


Log in to reply