Temperature bug/feature?

  • Fusionftw
    31st Oct 2017 Member 0 Permalink

    Say you place a pixel of wifi and set the temp to 202C. If you save and reload it, the tempature goes from 202C to 201.85C. Why does this happen? Does it have something to do with how the memory is stored?

  • coryman
    31st Oct 2017 Member 0 Permalink

    Absolute 0 is -273.15C, or 0K. I believe the game stores rounded values in Kelvin, so 202C is 475.15K. If you round that to 475, then convert back to Celcius, it gives you 201.85C. That's my guess anyways

  • Draco712
    31st Oct 2017 Member 0 Permalink

    coryman's probably right, and that happens to maybe any particle with temperatures above 149C I think. Those lower than 149C doesn't seem to be affected. The game rounds it off to maybe reduce the size of a save.

  • LBPHacker
    31st Oct 2017 Developer 1 Permalink

    A quick glance at the code confirms that temps are optimised when they are near room temperature. If the temperature can be represented as the sum of the room temperature (21C, 294.15K) and a 8-bit signed integer (which is in the in the interval [-128; 127]), it is actually saved as this signed 8-bit offset. This means temperatures in the interval [-107C; 148C]*. If not, it's saved as a full 16-bit integer (in the interval [0; 10000]).

     

    In both cases the temp is saved as an integer, but when the offset from 21C is saved, at load time it's calculated as offset + 294.15, thus becoming a non-integer value on the Kelvin scale but an integer value on the Celsuis scale. On the contrary, when it's saved as a full 16-bit integer, it stays an integer value on the Kelvin scale but ends up being a non-integer value on the Celsius scale (.85, or .15 when below 0).

    *: That is actually not true as the lowest temperature that can be saved in its integer form is -105C. I guess the game tries to be on the safe side with interval checks.

    Edited once by LBPHacker. Last: 31st Oct 2017
  • Fusionftw
    31st Oct 2017 Member 0 Permalink

    oh. So the tempature is actually due to optimization.