Graphics

 View Only
  • 1.  Math Not Calculating Correctly

    Posted 09-11-2015 18:40
    So I've set up something in Visual Logic to take a value from Object A and the value of Object B to determine the value of Object C. The values are the numbers in the text field, which are then multiplied to get a decimal for percentages (Multiply by .010). So if the text value of Object A is 70 (.70) and the text value of Object B is 25 (.25), then Object C becomes 5 (.05). Make sense?

    However, in Visual Logic, when the values are multiplied, they come out at 15 or so decimals (so 30*.010= .2999998... so on and so forth), which is messing up the rest of my visual logic math.

    Should I be going about this a different way? Bascally, this is for a bar graph for three outcomes. If bar A (.7) + bar B(.3) = 1, then bar C will not show up. But for some reason, none of the math is coming out right, and it is making bar C show up. Very basic stuff, so basic that maybe that's why I'm missing it. If you need the file, I'll provide it.


  • 2.  RE: Math Not Calculating Correctly

    Posted 09-12-2015 00:23
    Could you post a screenshot of your visual logic?

    It sounds like you are trying to compare the calculated value with a fixed value like 1.0 in order to determine if something should show or not. If so, you should be able to resolve this by checking if the value is greater than 0.999 and less than 1.001.

    #XPression


  • 3.  RE: Math Not Calculating Correctly

    Posted 09-12-2015 00:38
    This link essentially explains what you are seeing: Floating Point Numbers

    You can use the FormatFloat block in the strings category to round the number to X number of decimal places before you display it in a textbox; and tricks like greater than/less than comparison i described in the last post to deal with this type of lack of precision.

    #XPression