Calcualting with Decimals

J

jellis79

I am using a text box to calculate several other text boxes with Currency
values. I have set all the text boxes so they only display 2 decimals. When
the figures are all added together, it is adding with five decimal places so
the total is not correct. Even though only 2 decimals are displayed it is
still adding with five decimal places.
Thanks for any input!
 
S

Scott Roberts [MSFT]

Unfortunately, data formatting doesn't determine what precision is used for
doing calculations. It merely determines what to display. There's no way
that I know of to specify that the calculations should be to two decimal
places. You can try using the round() XPath function but I don't think that
will give you the precision that you need

- Scott
 
J

jellis79

I try it, but did not have much luck. I thouht maybe I should gice you more
info. This is what the calculation looks like.
field1 * field2 * field3
example 57 * 0.71166 * 7 = 40.56462

I 'm trying to get it to drop off the 462. I've read about the roundFloat
function you can paste in your forms script.js but I can not figure out how
to implement the function.

Thanks for the help!



Alex said:
Here is a workaround: if you want to add two fields with precision of 2
decimal places, use the following default value for the calculated
field:

(round(field1 * 100) + round(field2 * 100)) * 0.01


-----Original Message-----
From: Scott Roberts [MSFT]
[mailto:[email protected]]
Posted At: Thursday, May 12, 2005 1:12 PM
Posted To: microsoft.public.infopath
Conversation: Calcualting with Decimals
Subject: Re: Calcualting with Decimals

Unfortunately, data formatting doesn't determine what precision is used
for
doing calculations. It merely determines what to display. There's no
way
that I know of to specify that the calculations should be to two decimal

places. You can try using the round() XPath function but I don't think
that
will give you the precision that you need

- Scott


jellis79 said:
I am using a text box to calculate several other text boxes with Currency
values. I have set all the text boxes so they only display 2 decimals.
When
the figures are all added together, it is adding with five decimal places
so
the total is not correct. Even though only 2 decimals are displayed it is
still adding with five decimal places.
Thanks for any input!
 
J

jellis79

Worked perfectly, Thanks for your help!

Alex said:
If you just want to drop, not round off, the result - use this:

round(field1 * field2 * field3 * 100) * 0.01

Good luck.
Alex @ Microsoft

-----Original Message-----
From: jellis79 [mailto:[email protected]]
Posted At: Friday, May 13, 2005 8:16 AM
Posted To: microsoft.public.infopath
Conversation: Calcualting with Decimals
Subject: Re: Calcualting with Decimals

I try it, but did not have much luck. I thouht maybe I should gice you
more
info. This is what the calculation looks like.
field1 * field2 * field3
example 57 * 0.71166 * 7 = 40.56462

I 'm trying to get it to drop off the 462. I've read about the
roundFloat
function you can paste in your forms script.js but I can not figure out
how
to implement the function.

Thanks for the help!



Alex said:
Here is a workaround: if you want to add two fields with precision of 2
decimal places, use the following default value for the calculated
field:

(round(field1 * 100) + round(field2 * 100)) * 0.01


-----Original Message-----
From: Scott Roberts [MSFT]
[mailto:[email protected]]
Posted At: Thursday, May 12, 2005 1:12 PM
Posted To: microsoft.public.infopath
Conversation: Calcualting with Decimals
Subject: Re: Calcualting with Decimals

Unfortunately, data formatting doesn't determine what precision is used
for
doing calculations. It merely determines what to display. There's no
way
that I know of to specify that the calculations should be to two decimal

places. You can try using the round() XPath function but I don't think
that
will give you the precision that you need

- Scott


jellis79 said:
I am using a text box to calculate several other text boxes with Currency
values. I have set all the text boxes so they only display 2
decimals.
When
the figures are all added together, it is adding with five decimal places
so
the total is not correct. Even though only 2 decimals are displayed
it
is
still adding with five decimal places.
Thanks for any input!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top