# Can Inform do percentage?

I scanned through the arithmetic chapters and didn’t find anything.

I want to say something along the lines of:

If dealtdamage > (90% of maxdamage):
[something happens].

But Inform doesn’t like it.

Do I just need to calculate it all out mathwise?

If dealtdamage/maxdamage > .9

?

I wonder, can you do this?

``100% specifies a real number scaled up by 100.``

If not:

``To decide what real number is (P - a real number) % of (N - a real number): decide on N * (P / 100).``

Both of those threw errors, and my >.3 version doesn’t seem to work because Inform thinks the decimal is the end of the sentence.

``````To decide what real number is (P - a real number) % of (N - a real number): decide on N * (P / 100).

When play begins:
let N be 90 % of 200;
say "N is [N].";``````

Note the spaces around the % symbol.

I tried this:

[code]A whole-unit is a kind of value. 1x specifies a whole-unit. 100% specifies a whole-unit scaled up by 100.

To decide which number is (percentage - whole-unit) of (n - number):
decide on (percentage * n) / (1 whole-unit).

Lab is a room.

When play begins:
say “150% of 3 is [150% of 3].”[/code]

and it threw an error on every single line in the Standard Rules involving the word “of.” Well, not really, but “let contents form of list be true” and “the number of things carried by the actor is at least the carrying capacity of the actor” and some other things. So I think trying to define a phrase with “of” is going to confuse the ni parser (or whatever you call it).

You ought to be able to fix your > .3 problem with a leading 0, by writing > 0.3. And you shouldn’t have to reorder your calculation; I’d guess that

``If dealtdamage > (0.90 * maxdamage):``

should work. (Or you could do the one with a space around the %; it depends on whether the mental effort required to remember to put in the leading 0 in the decimal is greater than the mental effort required to put a space before the %.)

EDIT: It might be more idiomatic to replace % with percent spelled out:

[code]To decide what real number is (P - a real number) percent of (N - a real number): decide on N * (P / 100).

When play begins:
let N be 90 percent of 200;
say “N is [N].”;[/code]