Author Topic: [FIXED] Storage Space issue  (Read 2339 times)

Offline evilbananas

  • Squaddie
  • *
  • Posts: 2
    • View Profile
[FIXED] Storage Space issue
« on: June 06, 2022, 06:14:56 pm »
I have a base that has 225 storage space.  The only thing in the base is scrap metal as you can see in the attached screenshots below. 

If I try to transfer 1 more piece of scrap metal to reach my storage limit of 225, I get an error that their is not enough space at the base.


« Last Edit: February 02, 2023, 03:27:46 pm by Meridian »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Storage Space
« Reply #1 on: June 06, 2022, 07:22:19 pm »
Space is not integer, you could have 224.1 used space. Save could be more productive to see what exactly code did there.

Offline R1dO

  • Colonel
  • ****
  • Posts: 442
    • View Profile
Re: Storage Space
« Reply #2 on: June 06, 2022, 07:49:41 pm »
It is probably due to floating point calculations.

From your second screenshot it can be observed the base is only 1 item away from the max amount (storage space 224.9 vs 225), which means (up to) 0.1 space available.
Unfortunately 0.1 has no exact representation in floating point, the closest one can get is something like:
"0.100000001490116119384765625" [1]
This number is slightly larger causing the result after transfer to be larger than 225 leading to the mentioned error.

P.s. This is assuming OXC(E) does not take into account floating point accuracy when comparing base fill levels (have not looked at that part of the code).

[1] Courtesy: 1st answer of following stackoverflow post => https://stackoverflow.com/questions/3448777/how-to-represent-0-1-in-floating-point-arithmetic-and-decimal

Offline evilbananas

  • Squaddie
  • *
  • Posts: 2
    • View Profile
Re: Storage Space
« Reply #3 on: June 06, 2022, 08:11:57 pm »
I have attached the save file to the original post.  It's for the latest X-Piratez - N1.1

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9098
    • View Profile