Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Division by zero

Avatar

Former Community Member
I am trying to calculate a BMI with weight and height fields

the formula is weight / height (m) squared

Right now people will input weight in Kg and Height in cm

Then I have created a new field which will convert the height into meters and then square it. This reads

(Height/100) * (Height/100)



Then I tried using an "if" because without it I get an error suggesting division by zero.

So I tried

if (x <>0) then Weight/x

When I do this I get an error suggesting a syntex error involving x

Please help.



I am new to this so even if you can create the code for the BMI calculation so I can copy it that would be great

Thanks

Kelly
1 Reply

Avatar

Former Community Member
Kelly, initially, I would suggest you have your weight and height measurements in the same type of units (kg or cm) and write your code when you square it as (Height * Height). Your code of x<>0 seems as though it would generate an error as the program would read it as less than and great than 0. Sometimes you get errors that say one thing but the snytax is missing a parenthesis or a quotation mark, so I would go back over your syntax. Hope this helps.



Josephine