Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8834851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:07:18+00:00 2026-06-14T09:07:18+00:00

I have a simple function #define AMB_FILTER 0.7f int32_t fValue; (this is declared in

  • 0

I have a simple function

#define AMB_FILTER 0.7f

int32_t fValue; (this is declared in the class header)

int32_t Ambient::filter(uint32_t raw)
{
    // If we have no preliminary fValue we don't need to calculate a filter
    if(fValue == -1)
    {
        fValue = raw;
        return fValue;
    }

    float y, yy;

    y = (1.0f - AMB_FILTER) * (float) raw;
    yy = AMB_FILTER * (float) fValue;

    fValue =  (int32_t) (y + yy);

    printf("filter raw %d y %f yy %f fValue %d\n",raw, y, yy, fValue);

    return fValue; 
}

It takes in a value that was read from smbus and returns a value that was filtered with the last value it received. Here is its output from the printf statement

filter raw 454 y 136.200012 yy 317.799988 fValue 454
filter raw 454 y 136.200012 yy 317.799988 fValue 454
filter raw 454 y 136.200012 yy 317.799988 fValue 454
filter raw 455 y 136.500000 yy 317.799988 fValue 454
filter raw 455 y 136.500000 yy 317.799988 fValue 454
filter raw 455 y 136.500000 yy 317.799988 fValue 454
filter raw 455 y 136.500000 yy 317.799988 fValue 454
filter raw 455 y 136.500000 yy 317.799988 fValue 454
filter raw 454 y 136.200012 yy 317.799988 fValue 454
filter raw 455 y 136.500000 yy -731751040.000000 fValue -731750912
filter raw 455 y 136.500000 yy -512225632.000000 fValue -512225504
filter raw 455 y 136.500000 yy -358557856.000000 fValue -358557728
filter raw 455 y 136.500000 yy -250990400.000000 fValue -250990256
filter raw 454 y 136.200012 yy -175693184.000000 fValue -175693040

So what is happening? How is it that it still received the same input but all of a sudden went crazy? I don’t set the fValue anywhere but this function.

I made these variables (y and yy) very internalized to the function because I was worried they were somehow being modified or collided with something else. But now that they are completely local I have no idea what is happening. I am using C++ classes so this should all be in its own space anyhow.

EDIT: In fact if I let it run a little longer the variables I keep for the different i2c Chip addresses also become corrupted to -1075766188. What the hell?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:07:20+00:00Added an answer on June 14, 2026 at 9:07 am
    [t1] filter raw 454 y 136.200012 yy 317.799988 fValue 454
    [t2] filter raw 455 y 136.500000 yy -731751040.000000 fValue -731750912
    

    Sometime between t1 and t2 the value of fValue was corrupted. The corruption of yy is a consequence of fValue‘s corruption. Look elsewhere in your program for the culprit.

    • If you can’t use valgrind, then sprinkle sanity checks on the valueof fvalue throughout your program.
    • Print the value of this in your routine. See if it becomes unusual.
    • Print the value of other member variables from Ambient. See if they become unusual.
    • Try commenting out huge tracts of code. Start with 1/2 of your program. If the bug is still there, comment out 1/2 of the remainder. Continue until you find a single line that controls the corruption.

    As to how it was corrupted, there are many possibilities. Perhaps you dereference a wild pointer somewhere. Perhaps you write beyond the end of an array. Perhaps you are operating on a previously destroyed Ambient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple class ina header file: > cat Algorithms.hh #ifndef Algorithms_hh #define Algorithms_hh
I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });
When I was reading the nginx code, I have seen this function : #define
I have wrote simple macro to define interactive function and bind it to key
I have a small sample function: #define VALUE 0 int test(unsigned char x) {
It's a very simple program. I have a function defined on the top and
I have a simple function as the following: static Task<A> Peirce<A, B>(Func<Func<A, Task<B>>, Task<A>>
I have a simple function that looks at an incoming mySQL data type and
I have a simple function that works in chrome, but in Internet explorer (9)
I have a simple function, which I shall call myFunction . It takes two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.