This wiki is a read-only version of the Stardew Valley Wiki. The official editable wiki maintained by ConcernedApe can be found at stardewvalleywiki.com

Talk:Wheat

From Stardew Valley Wiki
Jump to: navigation, search
This talk page is for discussing Wheat.
  • Sign and date your posts by typing four tildes (~~~~).
  • Put new text below old text.
  • Be polite.
  • Assume good faith.
  • Don't delete discussions.

Rounding Problem

PHP has a rounding problem due to its poor implementation of floating point numbers (see this PHP manual page), and some of the math on the wiki is affected, including this page - the Tiller profession pricing is incorrect compared to in-game pricing; silver should be 34g and gold should be 41g. Not sure how this should be handled since I don't really know how many values are affected by this bug. 01:28, 27 January 2020 (UTC)

It's a wiki-wide bug. The root cause is that we can't replicate the in-game calculations properly without installing extensions. The good news is that prices are only off by one. margotbean (talk) 01:41, 27 January 2020 (UTC)
I investigated bonus rounding over two years ago while attempting to get my spreadsheet to register prices correctly and automatically. I found that the order of operations matters. You must figure the quality bonus first from the base price, rounding off the result. Then you must apply the Tiller bonus to the rounded quality price, rounding again. Incorrect results occur if you attempt a different order or try to apply both bonuses before any rounding, often with errors by one. Is this the cause of your problems? If so, it's not really because of a "poor implementation of floating point numbers", which is a highly suspect claim, given that that logic is generally located on-chip in the CPU.
BTW, the IEEE standard is a standard because this is the way floating point numbers work. It's the best implementation we can do. Real numbers are continuous, but computer simulations of fractions have always been limited to a certain degree of accuracy. Continuity would require infinite precision, and therefore infinite memory. Try representing PI or the square root of two, for example. This, and the resulting error accumulations during calculation, have been known in scientific computing for over 70 years. There are numerical methods necessary to address the issue in specific problems, all with limited success as well. Computing still beats calculation by hand. But it's still necessary to validate results. Butterbur (talk) 17:21, 27 January 2020 (UTC)
MediaWiki is still incorrectly calculating the equation, though. It's truncating every number in the equation, rather than only truncating the result. TRUNC() in most languages doesn't behave this way. The Wiki's math is wrong - check the price in-game at Pierre's and you'll find that some numbers on the wiki are off by one. I haven't played with MediaWiki in awhile, but it seems like it should be possible to calculate the result as a float or double, THEN run it through the truncate function. We're not talking huge numbers here - the silver bonus for wheat at 25g is only 25 * 1.25 * 1.1, which equals 34.375. If I can do the math with pencil and paper and get the right answer, this definitely isn't a problem of floating point numbers in C or C++ being unable to handle accurate math with a very small number. It's MediaWiki deciding to implement a truncate math function that doesn't behave like truncate anywhere else. Clairelyclaire (talk) 03:10, 29 January 2020 (UTC)
Yes, the Wiki numbers are off. To repeat, floating point calculation is done by the CPU, not by C or C++. A programming language is a translator that creates the hardware instructions that make the CPU do the work. A TRUNC() function is different. That's a set of instructions, a program. If MediaWiki programmed theirs wrong, I'm sure that it's messy for a Wiki to try to get around it. I think Margot is saying that it's not perfect, but it's not worth the trouble to fix. (It COULD be a ton of trouble for very little benefit.) Be advised that MediaWiki is not the only offender regarding one of its functions. Microsoft Excel has, for decades, programmed some of its functions wrong, justifying it by saying that its customers didn't understand how they're supposed to work and wanted it to work the way they have it programmed. (TRUNC is one of those.) It seems the floodgate is open for everyone to generate their own version of how they think it should work. You're not alone in being frustrated. Butterbur (talk) 06:57, 29 January 2020 (UTC)