### Re: Math error involving .00 and .02

Posted:

**Thu Jan 07, 2016 2:05 pm**What about doing the math server side?

eg: SELECT 1 + 1 AS SumTotal

eg: SELECT 1 + 1 AS SumTotal

Community Support for NeoBook, NeoPaint and NeoAppBuilder

http://www.neosoftware.com/community/

http://www.neosoftware.com/community/viewtopic.php?f=21&t=21421

Page **2** of **2**

Posted: **Thu Jan 07, 2016 2:05 pm**

What about doing the math server side?

eg: SELECT 1 + 1 AS SumTotal

eg: SELECT 1 + 1 AS SumTotal

Posted: **Sat Jan 09, 2016 8:43 am**

First of All, thank you for all the suggestions for work around regarding the Math function and getting 'pennies' to calculate right.

It was very frustrating and I thought I would have to live with the flaw.

I used variables not Database fields to do the calculations.

So far testing indicates the calculations are performed as expected.

The Subroutine which now seems to work is:

Thank you for taking the time to help.

It was very frustrating and I thought I would have to live with the flaw.

I used variables not Database fields to do the calculations.

So far testing indicates the calculations are performed as expected.

The Subroutine which now seems to work is:

- Code: Select all
`:UpdateAccountBalance`

. update account balance when adding Journal Entry record

dbpFind "NBAccounting" "Gl" "AccountNo" "[NBAccounting.JrDetails.AccountNo]" "ExactMatch=Yes;CaseSensitive=No"

. ONE

IfEx "[NBAccounting.Gl.NormalBalance]= DB AND [NBAccounting.JrDetails.InAmt] > 0"

SetVar "[vDebitAmt]" "[NBAccounting.JrDetails.InAmt]"

SetVar "[vDBBalance]" "[NBAccounting.Gl.DBBalance]"

Math "[vDBBalance]+[vDebitAmt]" "2" "[NBAccounting.Gl.DBBalance]"

EndIf

.TWO

IfEx "[NBAccounting.Gl.NormalBalance]= DB AND [NBAccounting.JrDetails.OutAmt] > 0"

SetVar "[vCrAmt]" "[NBAccounting.JrDetails.OutAmt]"

SetVar "[vDBBalance]" "[NBAccounting.Gl.DBBalance]"

Math "[vDBBalance]-[vCrAmt]" "2" "[NBAccounting.Gl.DBBalance]"

EndIf

.THREE

IfEx "[NBAccounting.Gl.NormalBalance]= CR AND [NBAccounting.JrDetails.InAmt] > 0"

SetVar "[vDebitAmt]" "[NBAccounting.JrDetails.InAmt]"

SetVar "[vCRBalance]" "[NBAccounting.Gl.CRBalance]"

Math "[vCRBalance]-[vDebitAmt]" "2" "[NBAccounting.Gl.CRBalance]"

EndIf

.FOUR

IfEx "[NBAccounting.Gl.NormalBalance]= CR AND [NBAccounting.JrDetails.OutAmt] > 0"

SetVar "[vCrAmt]" "[NBAccounting.JrDetails.OutAmt]"

SetVar "[vCRBalance]" "[NBAccounting.Gl.CRBalance]"

Math "[vCRBalance]+[CrAmt]" "2" "[NBAccounting.Gl.CRBalance]"

EndIf

dbpSaveEdits "NBAccounting" "gl"

Return

Thank you for taking the time to help.