Topic: COOK_WEIGHT_DIV rounds down odd-valued nutrition  (Read 4359 times)


koteko

« on: February 15, 2018, 08:17:24 AM »
tested on 3.5b2

In most cases (eg, bear and elk meat) the nutrition numbers (be them fat, carbs or proteins) are multiplied by COOK_WEIGHT_DIV just as the weight is divided by it.

However, when the weight is very small and the nutrition value is odd, sometimes you get the right nutrition value and sometimes you don't.

An example is probably best to explain this.

Let's use two recipes (thanks @caethan):

Code: [Select]
.Grey sludge. *COOKERY* /1/
[SPOILAGE_DAYS:0]
[CARB:7]
[PROTEIN:3]
[FAT:5]
[WEIGHT:0.2]

.Dried sludge. *COOKERY* /1/
{Grey sludge}  [remove] [roast]
[COOK_WEIGHT_DIV:2]

If we create this grey sludge and inspect the OBJ file, the nutrition is as we defined and weight is 0.2 lbs.

When we make the Dried sludge, we get weight 0.1, fat 10, carbs 14 and proteins 6. So all good for now, the nutrition is multiplied by 2, and the weight is divided by 2 as normal.

If we set the Grey sludge's weight to 0.15, ie:

Code: [Select]
[WEIGHT:0.15]
and then we make dried sludge, we get weight 0.075, fat 8, carbs 14 and proteins 6. What happened to fat?! Everything else is multiplied by two, but it looks like fat was decreased to 4 and then multiplied by 2.

What happens if we set initial sludge weight to 0.1?

Code: [Select]
[WEIGHT:0.1]
We dry, and get: weight 0.05, fat 8, carbs 12 and proteins 4. So now all three nutritional values seem to have been rounded down.

There is something wrong for sure :)

koteko

« Reply #1 on: February 15, 2018, 05:09:34 PM »
For a real use case where this happened (ie, drying blueberries), see here: http://www.unrealworld.fi/forums/index.php?topic=1113.0

caethan

« Reply #2 on: February 15, 2018, 05:36:23 PM »
Oh interesting, I didn't realize it's related to the weight.