in
Creating Smarter Networks

Problem with Float Data

Last post 05-20-2009 12:37 AM by troggendorf. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-17-2008 6:30 AM

    • nfitzy
    • Top 50 Contributor
    • Joined on 11-21-2008
    • Posts 4
    • Points 80

    Problem with Float Data

    Hi All,

    I am programing a test FPM to get familiar with the iLON programming enviroment. In this module I am passing a float data point (sm_freqadjprice_temp ) from the Data Point view on the iLON home page which is then read in by my FPM. I am then doing some simple checks eg.

    if (sm_freqadjprice_temp == 49.1)
            {
                sm_FreqAdjPrice = 99.9;
            }
            else
            {
                sm_FreqAdjPrice = 11.1;
            }

    When I entered 49.1 in the data point view I kept getting a return value of 11.1 (false) rather than 99.9 (true). As sm_freqadjprice_temp = 49.1 (49.1 == 49.1) the result should be true.

    I decided to printf the value being read in from the data point view screen and I got strange results:
    If I entered the following:

    Entered           Value being pass to program and onto printf
    49.1                49.0999980
    49.2                49.2000010
    49.3                49.2999990 etc....

    Also the same occurs if I let a float = 49.1 in code and the do a printf I get 49.0999980.

    Have you ever seen a problem like this with Floats?

     Thanks for the help.

    • Post Points: 20
  • 05-20-2009 12:37 AM In reply to

    Re: Problem with Float Data

     Sure, if some calcullations are done between entering and printing then this is to be expected.

    • Post Points: 5
Page 1 of 1 (2 items)
©2008 Echelon Corporation