2
$\begingroup$

I am programming a script to an online store and a serious mathematical problem happened, and I cannot solve it!

This is the problem: if a person has only 10 cents (on any monetary currency, I will use US Dollar for example) it's the same as say that this person has $ 0.1 right?

I mean 10 cents = $ 0.1 , right?

Now, lets square it. The 10 cents becomes 100 cents, which is 1 dolar. Right? But 0.1*0.1 = $0.01.

I am very sure I can do this math using cents OR using any other unit I want and the result should be the same. If I have the same example and I want to make the square with a number that is in meters and other is in kilometer. The result should be the same, but it is not! What is the issue here?

EDIT:

One final question, a function with $x^3$ should increase faster than $x^2$ right?

For example, $2^2 = 4$ and $2^3 = 8$ $10^2 = 100$ and $10^3 = 100$

So the $x^3$ graphic should always be on top of $x^2$. Why doesnt that happen all the time?

OBS: this edit looks not related to my main question but it is completely, depending on the answer.

$\endgroup$
  • 19
    $\begingroup$ The units change when you square things - one square dollar = 10,000 square cents - just like one square metre = 10,000 square centimetres $\endgroup$ – Mark Bennet May 21 '15 at 16:54
  • 6
    $\begingroup$ An interest rate, in the form $1+r$ where $100r$ is the percentage rate, is a dimensionless ratio between the sum of money at the end and the sum at the beginning $\endgroup$ – Mark Bennet May 21 '15 at 16:57
  • 15
    $\begingroup$ taking mental note of carefully checking the units before shopping at sitepor500.com.br $\endgroup$ – mickep May 21 '15 at 17:01
  • 5
    $\begingroup$ So this is what happened in 2008. $\endgroup$ – Calum Gilhooley May 21 '15 at 17:40
  • 9
    $\begingroup$ If there are units of currency occurring anywhere in your interest rates, you're doing it wrong. Plainly and simply wrong. Go back and correct whatever mistaken idea caused the $\$^{-1}$ to sneak into your interest rate, correct or re-do everything that was affected by that mistaken idea, and be careful not to make that mistake again. $\endgroup$ – David K May 21 '15 at 18:39
16
$\begingroup$

The problem is you aren't keeping track of the units properly. $(10\textrm{ cents})^2=100\textrm{ cents}^2$ whereas $(\$0.1)^2=\$^20.01$. Note that since $100\textrm{ cents}=\$1$, we have that $10000\textrm{ cents}^2=\$^21$. Using this unit conversion, the equality that looked weird to you holds.

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ AMAZING!!! I SPENT MANY DAYS INTO THIS!!! Thank you A LOT! I will save the squared unit in my database and make sure when I change to another unit I make the correct conversion! $\endgroup$ – Sitepor500.com.br May 21 '15 at 16:57
  • $\begingroup$ @Sitepor500.com.br Glad to be helpful :) $\endgroup$ – jgon May 21 '15 at 16:58
  • 1
    $\begingroup$ @Sitepor500.com.br consider accepting this answer to let other users know that this is the right one. $\endgroup$ – SalmonKiller May 21 '15 at 16:58
  • 2
    $\begingroup$ @SalmonKiller Not necessarily that it is the right one per se but the most helpful ;) $\endgroup$ – Daniel W. Farlow May 21 '15 at 16:59
  • $\begingroup$ I am trying to accept this answer but SE says I need to wait more 6 minutes. I will do that :) I am very glad to you. $\endgroup$ – Sitepor500.com.br May 21 '15 at 17:00
6
$\begingroup$

The calculation is correct (though you have named the units incorrectly).

I doubt you have a problem with the fact that 1 yard = 3 feet, but 1 square yard = 9 square feet. It's the same sort of thing.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ You are right, I edited the question can you help me answer the bottom of it? $\endgroup$ – Sitepor500.com.br May 21 '15 at 17:03
  • $\begingroup$ It's unrelated. You should pose it as another question. Piggybacking questions is frowned upon. Post another and I will read it. $\endgroup$ – MPW May 21 '15 at 21:48
4
$\begingroup$

If you square 10 cents, then you have 100 "square-cents". If you square 0.1 Dollar, then you have 0.01 "square-Dollars". Now, 100 "square-cents" is the same as 0.01 "square-Dollars".

Maybe it's not such a good idea to square money...

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ squaring money is needed in my case cause I need it to calculate intererest rate of a purchase that is made in several months. I use a strange formula from my customers that squares everything including the money, not only the interest rate. $\endgroup$ – Sitepor500.com.br May 21 '15 at 16:59
  • $\begingroup$ It is a good idea to never pass around raw numbers or strings in code for this reason. It's the main reason why constructors exist: d := Dollar(0.1); c := Cents(d.toCents()). $\endgroup$ – Rob May 21 '15 at 18:17
2
$\begingroup$

Although there are many correct answers already posted, I'd like to post an answer that is easier to read and conceptualize.

If you have \$0.10 and you want to collect ten of them, then the calculation is simple: "10 x \$0.10 = \$1", which is what you expect.

Conversely, when you say you want to "square" ten cents, what you're really saying is you want to "ten cents the ten cents", which doesn't make any sense.

Alternatively, if you view each cent as one percent (which is where the term "percent" came from, "per cent" or "per one hundred"), ten cents is thus 10%, which if squared, means "10% of 10%", which is 1%.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ I never heard that analogy that percent is "per cent". Really nice man. Great explanation $\endgroup$ – Sitepor500.com.br May 22 '15 at 0:13
1
$\begingroup$

You probably don't want to square the money (otherwise, the unit would change from cents or $\$$ to cents^2 or $\$^2$, and the result you get in these units is not a contradiction); more likely, you expect a result tantamount to multiplying the amount by 10.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ But I need to use interest rate that was converted from % to $ that's why I need to square it. Can you also help me answer the bottom of my question? $\endgroup$ – Sitepor500.com.br May 21 '15 at 17:04
  • $\begingroup$ % is a ratio without units (call it the unit 1). 90% could come from: (9 dollars)/(10 dollars) = 0.9 = 90%. If you want a percentage of an original amount: \$600 * 90%, which is in dollars. ((\$600 * 90%) * 90% )* 90%) = \$600 * (90% * 90% * 90%) is in dollars as well. Notice that the rate keeps getting exponentiated, not the dollars. $\endgroup$ – Rob May 21 '15 at 18:32
  • $\begingroup$ For you last question: $x^3 > x^2$ when $x > 1$; the behavior is opposite for $0 \leq x <1$. $\endgroup$ – Clement C. May 21 '15 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.