I thought about this problem from a financial standpoint and didn't like the default ruby or rails options that have been given so far because of how much lost revenue could be happening. Amazon for example has over a billion transactions a day (according to the first link on google). If we use 1.3 billion transactions and assume that the average fractional cents that they give up in a day of transactions is half a cent (.05). That would cost them 6.5 million dollars in lost revenue from giving up fractions of a cent. My solution just trims the number instead of rounding it.
I could see potential for wanting to round up from a business standpoint too, if the calculations are creating a price point for your product in a currency form then by all means you want to round up to still avoid that 6.5 million hit. In which case you would have to adjust the currency function.
This problem can really get interesting depending on your outlook.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I thought about this problem from a financial standpoint and didn't like the default ruby or rails options that have been given so far because of how much lost revenue could be happening. Amazon for example has over a billion transactions a day (according to the first link on google). If we use 1.3 billion transactions and assume that the average fractional cents that they give up in a day of transactions is half a cent (.05). That would cost them 6.5 million dollars in lost revenue from giving up fractions of a cent. My solution just trims the number instead of rounding it.
I could see potential for wanting to round up from a business standpoint too, if the calculations are creating a price point for your product in a currency form then by all means you want to round up to still avoid that 6.5 million hit. In which case you would have to adjust the currency function.
This problem can really get interesting depending on your outlook.