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.

Negative Numbers in calculations

Avatar

Level 4

I'm having some problems with getting calculations to show negative numbers.  I have attached a screenshot of what I'm trying to do.  I had a problem with the over/under flow which I solved with the "if" command, but Lines 27 and 28 need to show negative numbers when it calculates.   Can anyone help?

Thanks

Connie

Calculations.png

3 Replies

Avatar

Level 10

Should it dsplay always negative results?

Then use these combined display patterns.

null{0}|zero{0}|num{'-'z,zzz,zz9.88}

To avoid a arithmetic over/underun ensure the calculation does only execute when the input values are not 0.

if (Row25.TonLifeVOC ne 0 and Row24.Match ne 0) then

     Row24.Match / Row25.TonLifeVOC

endif

Avatar

Level 4

Hi radzmar.  In answer to your question, I need to be able to show negative and positive numbers depending on the data entered.  Right now it only shows positive numbers.  Can I still use what you recommended above or is there another way to show both positive and negative numbers in a calculation based on user input in other fields?

Thanks much for your help.

Avatar

Level 10

Well,

a numeric field generally shows negative values, if the calculated result is less than 0.

Assuming TonLifeVOC is -2 and Match is 10, then the result is -5 and will be displayed in that way.

The devision has to contain at least one negative value to return a negative result, otherwise it's always positive.