Select to view content in your preferred language

Adding a Decimal

821
7
02-02-2022 09:33 AM
ToddHill
New Contributor II

I'm hoping someone can point me in the right direction to add a decimal point in my last calculation. I have attached a screen shot of the calculation and the result on the form. I have also attached the XLSForm. All the calculations work perfectly except I need a decimal point after the first number. So instead of a result of 588, the result needs to be 5.88.

I have read through some of the post on decimals but unfortunately I didn't had any luck.

Thanks for any help in advance,

Todd Hill

 

0 Kudos
7 Replies
DougBrowning
MVP Esteemed Contributor

You are using int() in your calcs.  Integers have no decimal points so it is removing them.  Just remove the int() since all your fields are decimal anyways it is not needed.

JayantaPoddar
MVP Esteemed Contributor

As rightly mentioned by Doug, you may remove int() function, or replace it by number() function.

Also you might want to further multiply the expression by 0.01 in case you want to get 5.88 instead of 588.0 (as per your example screenshot.

 



Think Location
0 Kudos
ToddHill
New Contributor II

So when I add another 0.01 to the calc the answer came in as a 6. 

I attached a picture.

Thoughts? 

0 Kudos
ToddHill
New Contributor II

So I made the change you both suggested and I got the result I'm looking for but without the decimal point after the 5. 

Can either one of you tell me how the calculation should be to get the decimal point added?

See the attached screenshot of the XLS and the Form.

Thanks again for your help,

Todd

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

number(0.785 * ${D1} * ${D2} * ${PL} * 7.48 * 50 div ${cl2s} * 0.01 * 0.01)



Think Location
0 Kudos
AndyMcClary
New Contributor III

Also it looks like the field type for your gal field is integer. If you change that to decimal that should fix your problem.

JayantaPoddar
MVP Esteemed Contributor

You are right.

Initially (in XLSFORM), it was mentioned as Decimal, so I overlooked on that part.



Think Location
0 Kudos