5
$\begingroup$

I'm very new to Mathematica and I want to calculate percent multiplications. See below image. In In[3], I pressed space after 50% and then pressed 80%. Mathematica automatically added the multiplication sign. In In[4], I manually pressed *, the multiplication sign. Both seem not work. Where is the problem? Thanks.

enter image description here

$\endgroup$
6
  • 11
    $\begingroup$ % represents the last output. See Out in documentation. $\endgroup$
    – Kuba
    Sep 10, 2019 at 16:16
  • 10
    $\begingroup$ If you hate yourself, you can wrap everything with quantities: Quantity[50, "Percent"]*Quantity[80, "Percent"] means 50%*80%. The output will be 2/5 (not in percent), so not really useful. Why don't just use standard fractions instead, and multiply the result by 100 at the end to check the percentage? $\endgroup$
    – Fraccalo
    Sep 10, 2019 at 16:20
  • 3
    $\begingroup$ You could define your own symbol, e.g., ¢ = 0.01. $\endgroup$
    – Michael E2
    Sep 10, 2019 at 18:32
  • 5
    $\begingroup$ @MichaelE2 - Rather than always use machine precision, I believe an exact value would be better, i.e., ¢ = 1/100. At the end, machine precision can be coerced using N if desired. $\endgroup$
    – Bob Hanlon
    Sep 10, 2019 at 18:41
  • $\begingroup$ @BobHanlon That was my first choice, but then I thought better of it. I cannot recall ever being interested in exact percentages. I'd say use tool that does what you want. $\endgroup$
    – Michael E2
    Sep 10, 2019 at 19:58

1 Answer 1

6
$\begingroup$

The percent symbol % in Mathematica represents the last output Out[-1], see the Documentation for Out. Hence the results you observe.

In principle you can use Inline Free-form Input for this: press Ctrl+= and type your 50%, then press , * and Ctrl+= again and type your next percent quantity 80%, and so on:

screenshot

Then press Shift+Enter to perform the computation:

59/100

Alternatively you can take the suggestion by Michael E2 and define your own percent symbol like ¢ = 0.01 and then type 50¢ instead of 50% with similar effect:

screenshot

The symbol ¢ (\[Cent]) has built-in alias EsccentEsc. So there are two ways to type it in the FrontEnd: as \[Cent] or as EsccentEsc. It is also possible to define a keyboard shortcut for it using one of the methods described here:

$\endgroup$
2
  • $\begingroup$ I get the cent sign with the option key plus "4" but that may vary. $\endgroup$
    – Michael E2
    Sep 11, 2019 at 10:28
  • $\begingroup$ @MichaelE2 On my system (Win7) Alt+4 is a shortcut for the "Section" style. $\endgroup$ Sep 11, 2019 at 10:31

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