Big Reactors

Big Reactors

11M Downloads

Floating point value with rotorEnergy in Turbines.

hazzal opened this issue ยท 1 comments

commented

Heyo, I've noticed that you've chosen to define rotorEnergy with a floating point. I'm curious if it is intentional that the numbers get so damn high that the addition will become funny.

Example:
When you have a Turbine getting 2B/t steam, 80 blades accepting this steam, 32 Ludicrite blocks as inductor.
You're able to attain 2 different "stable speeds" as I prefer to call them due to the floating point arithmetic at these high values of rotorEnergy.

1780.9716 RPM
1780.9716 RPM

and
1782.3975 RPM
1782.3975 RPM

The "stable speed" you get depends which "way" you come from, if you start at 1800 RPM you'll land on 1782.3975 RPM but if you start up your turbine from 0 RPM it will land on 1780.9716 RPM.

This is because adding the two floats at line 559 in MultiblockTurbine.java you end up getting the same resulting rotorEnergy because:
1.3535384 * 10^8 + 7.9997063 = 1.3535384 * 10^8 when you're using floating points.

As you can see in the screenshot I added a bit more debugging info just for myself :)

This issue gets more entertaining if you do stuff like use 1 block of ludicrite to obtain ridiculous speeds you you can play around with turning on/off the coils as you desire to obtain the most efficient speed for energy output, since there is a lot of leeway due to the floating point arthrimetic.
^Do note that I know we're not supposed to use designs like this :)

I'm sorry but I don't have a viable solution at this moment other than using a double for rotorEnergy.
And sorry for any grammatical error etc, English is a second language for me.

commented

Yeah, I've been thinking about converting rotorEnergy to a double value due to the FP precision issue. I believe it originally was one (in the initial revisions of the code) and got crushed down to a float just because I didn't think it would really be necessary to use the full double's precision.

Probably something for 0.5.