cancel
Showing results for
Did you mean:
Helper II

## Division (Calculation) returns wrong result

Hi,

I have an issue with Flow calculating incorrectly.

``````variables('months') = 36
body('Get_record')?['netamount'] = 4704.48``````
``div(mul(body('Get_record')?['netamount'],100),variables('months'))``

Now, if I put this in a calculator. It solves to:

``````4704.48 * 100 = 470448
470448 / 36 = 13068``````

It seems that flow is not that good in calculating..?

Issue is that I need to round down the number that I get.

Yes I might be able to round by the Xth number or sth. but why can't it just calculate correctly in the first place?

Thanks!

3 REPLIES 3
Community Support

Hi @Serf ,

This is very strange. It seems like this issue is coming from the multiply expression. Take a look at what I did below. For some reason the mul(4704.48,100) expression when initialized in a float variable results in 470447.99999...

Let me follow up on my end and see if I can discover why this is happening.

Community Support

Hi @Serf

This is actually something called floating-point arithmetic that most programming languages deal with. They follow the following IEEE standard:
https://en.wikipedia.org/wiki/IEEE_754

I am working on figuring out a way to potentially do a rounding of sorts to get the correct number. You can see this reproduced in C# below.

Community Support

Hi @Serf

I would be wary of this solution, as I have not tested it extensively, but Flow is very limited on mathematical functions.

If you expect the number to always be a whole number, you can use the following equation in a compose action to convert the number to a string (which somehow rounds the number), split it between the decimal place, take the first part of the split which is your number, and then convert it to an integer.

int(first(split(string(variables('firstNumber')),'.')))

Announcements

#### Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

#### 2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

#### Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Top Kudoed Authors
Users online (1,720)