Rounding issue

From the JSON File:
Convert.ToInt32(Row(“cost”)) → Cost = .01
Convert.ToInt32(Row(“quantity”)) → Quantity = 1

Formula:
Assign “amt_per_quantity → Cost/Quantity = 0 (should equal .01)

Not sure how to set up the assign so its not rounding down to zero.

Hi @Waterfowl_Waterfowl_hunte ,

Maybe Try Converting to Double and check :
image

Hi,
Based on your description, you want to calculate Cost / Quantity . To ensure the result doesn’t round down to zero, you need to use floating-point division. Here’s how you can set up the formula in the right side of the assign
amt_per_quantity = Convert.ToDouble(Row(“cost”)) / Convert.ToDouble(Row(“quantity”))

I received this strange message when the debug reached the assign activity. This is a strange message i have never seen before. thoughts?

Change Inverted Double quotes to "

Hi,

Disable first two TotalPrice and Quantity assign activities. you already converted that rows to double in following assign.
Convert.ToDouble(Row(“cost”)) / Convert.ToDouble(Row(“quantity”))

Thank you @neha.upase. this worked! I appreciate the help.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.