- Bump - I now know better than to post on a Friday of a holiday and expect

anyone to see it ;)

--

Eddy

PCGen Doc Gibbon

> This is a request for clarification on how PCGen handles decimals.

>

> From my own experience with formulas I found that after all the math is done

> PCGen will return a whole number, discarding any decimal, is this right. Or

> is it returning the correct answer with a decimal which is then ignored when

> applied to whatever its used for. (either way it amounts to the same thing)

>

> Is this kind of truncation going on in division during the working of any

> formulas (I would guess not as this seems to be what the .TRUNC tag is for)

>

> Speaking of .TRUNC I find the example confusing, I'm not a programmer so I'm

> not familiar with the concept.

> it reads:

>

> (TL/3.TRUNC)*2

> Truncation - would divide TL by 3, truncate and then multiply by 2.

>

> This is a circular definition, my guess is that .TRUNC simply drops the

> decimal in effect rounding down.

> Is there any case where it rounds up?

> Is there an operator to make a number round up, or round to the nearest

> integer?

> Is there even a need for that?

>

> -------------------------------------

> Text from tracker:

> Under operators you give the example for division of

> CL/2. What the docs don't say is after the division what

> happens to the decimal. In long complicated formulas

> that would be important. > -----Original Message-----

I believe this is what happens.

> From: Eddy Anthony [mailto:eddyba@...]

>From my own experience with formulas I found that after all

>the math is done PCGen will return a whole number, discarding any

>decimal, is this right.

>Is this kind of truncation going on in division during the

It is not truncated until all processing is done unless the .TRUNC tag

>working of any formulas (I would guess not as this seems to

>be what the .TRUNC tag is for)

is used in the formula.

>Speaking of .TRUNC I find the example confusing, I'm not a

No, the above example would truncate 3 (useless) divide TL by that and

>programmer so I'm not familiar with the concept. it reads:

>(TL/3.TRUNC)*2

>Truncation - would divide TL by 3, truncate and then multiply by 2.

then multiply by 2 and then truncate that answer again.

(TL/3).TRUNC*2 would divide TL by 3, then truncate, then multiply by 2

and truncate again.

>This is a circular definition, my guess is that .TRUNC simply drops

It always truncates. No rounding up.

>the decimal in effect rounding down. Is there any case

>where it rounds up?

>Is there an operator to make a number round up, or round to the

No.

>nearest integer?

>Is there even a need for that?

Not that I've come across.

Barak

~ PCGen BoD

~ OS Silverback- Thanks Barak

So to sum up-

1) To truncate is to drop the decimal or in other words round down.

2) To truncate an operation one should enclose it in perenthisis like so:

(a+b).TRUNC (I'll be fixing the example in the docs).

One last question, can you truncate a variable? or this even nessissary?

For example DEFINE:FooDoo|CL/3

Will FooDoo already be truncated as it is the result of a completed formula?

Thanks for the info on the Total variable for the CONTAINS tag, I think I

have enough to make some edits.

--

Eddy

PCGen Doc Gibbon > Thanks Barak

No problem.

> So to sum up-

Correct.

> 1) To truncate is to drop the decimal or in other words round down.

> 2) To truncate an operation one should enclose it in perenthisis

Correct again (as I understand it)... PCGen has some strange ways of

> like so:(a+b).TRUNC (I'll be fixing the example in the docs).

determining precedence, but the above will guarantee that the

operation gets truncated and not just the last operand.

> One last question, can you truncate a variable? or this even

I think you could, but unless someone enters a decimal in the variable

> nessissary?

in a .lst file, I wouldn't see any need to.

> For example DEFINE:FooDoo|CL/3

Yes. That's how a lot of our SA tags that use variables work. To use

> Will FooDoo already be truncated as it is the result of a completed

> formula?

your example:

SA:Foo Doo Ability %/day|FooDoo

This would show nothing until third level and then it would show Foo

Doo Ability 1/day until sixth level where it would show Foo Doo

Ability 2/day, etc.

> Thanks for the info on the Total variable for the CONTAINS tag, I

Good! it's nice to see the docs being fixed up. Thanks to you and

> think I have enough to make some edits.

Shane!

Barak (at the local CC)

~ PCGen BoD

~ OS Silverback