Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trivial Ammonia recipe is an imperfect ratio
#1
Mixing ammonia, with 5 nitrogen and 15 hydrogen, leaves something like 7.0182461e-08 nitrogen when transferring 10u of diethylamide. Now, the chemicompiler decides that in a beaker with a hundredth of a millionth of a unit above 90, you can't transfer 10 units. This isn't an issue for normal chem mixing, since you can just remove all.
#2
Welcome to the world of rounding errors. Not really sure we can do anything about this. Leave more room in your beaker, I guess?
#3
idk jack about shit but couldn't some cleanup events just get rid of incredibly small chemical units, or is that not how byond works?
#4
(08-21-2018, 01:39 PM)cyberTripping Wrote: idk jack about shit but couldn't some cleanup events just get rid of incredibly small chemical units, or is that not how byond works?

Not really. You technically could make something that throws out numbers smaller than 10^-6 or something, but it would be a bad idea for several reasons. 

The largest is that it would add complexity to the code and hurt efficiency. So I think most people would agree that doing so is not worth the performance sacrifice since chem reactions do in fact already put a strain on the server at times. Now you might say, just change it in this specific instance. Again, not a terrible idea, but doing things like that for things where it's not 100% necessary can make the code very hard to maintain. It's just a drop in the ocean, but what is an ocean but a multitude of drops?

The other thing that needs to be mentioned here is this, Byond doesn't allow for you to cast numbers in a way to keep absolute precision. AFAIK. All Byond number types are floats and there is no simple way to work around that, like there would be if you were dealing with money transactions in Java and could just use a double type so you don't have rounding errors.

Also, if you want a more fun explanation, IRL mixing chemicals doesn't give you perfect reactions. There are impurities and stuff, just pretend that is what causes it.

So as Mordent said, just leave some more room in your beaker.
#5
(08-21-2018, 03:15 PM)kyle2143 Wrote: All Byond number types are floats,

oh no
#6
(08-21-2018, 01:04 PM)Mordent Wrote: Welcome to the world of rounding errors. Not really sure we can do anything about this. Leave more room in your beaker, I guess?

What about a button to round the amounts down to a whole number?

Is there no simple floor function?
#7
(08-23-2018, 04:24 AM)Sov Wrote:
(08-21-2018, 01:04 PM)Mordent Wrote: Welcome to the world of rounding errors. Not really sure we can do anything about this. Leave more room in your beaker, I guess?

What about a button to round the amounts down to a whole number?

Is there no simple floor function?

Oh, for sure there's other things we could do in terms of letting you do it. That'd be a feature request, not a bug, though! This bug is to do with the whole "BYOND uses imprecise floating point numbers" thing.


Forum Jump:


Users browsing this thread: 1 Guest(s)