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 5976185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:11:32+00:00 2026-05-22T21:11:32+00:00

[edit]Problem solved – kind of. There never really was a problem. It seems that

  • 0

[edit]Problem solved – kind of. There never really was a problem. It seems that the debugger was lying to me. Thanks[/edit]

I have a wierd problem that I’ve been unable to resolve so far. I have a private class member

private:
float *_histVals;

which is initialized in the constructor as follows:

// allocate memory for the histogram bins
size_t hSize = binsPerChan*binsPerChan*binsPerChan;
this->_histVals = new float[ hSize ];
for (size_t i = 0; i < hSize; ++i)
    this->_histVals[i] = 0.0f;

later in the program I want to add something to certain array elements in the following way:

this->_histVals[ hIndex ] += imgFrac;

Here, imgFrac is float value of the magnitude 1.0*e-5 and the current value of the _histVals[ hIndex ] Element is zero. However the debugger shows that after the execution of this line the value is still zero.

I suspected a problem with floating point precision but when I try the same thing with a local float variable it works perfectly. So it must have something to do with the array itself. But I’ve no idea what that possibly could be. I’ve also checked the index which is within array bounds.

Any suggestions what could cause the problem?
Thanks

  • 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-05-22T21:11:32+00:00Added an answer on May 22, 2026 at 9:11 pm

    Use std::vector<float> unless you want a difficult life or you’re learning how people had to live in the bad old days.

    Regarding this having no effect on the array element:

    this->_histVals[ hIndex ] += imgFrac;
    

    Possible causes:

    • The debugger is lying to you.
    • imgFrac is zero

    Have you tried logging all the values involved to std::cout? Also to convince yourself there’s no magic involved, try breaking it down into:

    float newValue = this->_histVals[ hIndex ] + imgFrac;
    this->_histVals[ hIndex ] = newValue;
    

    And log the newValue.

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

Sidebar

Related Questions

EDIT: Problem solved. This was (yet another) situation where the problem wasn't really where
EDIT: Problem solved by using $i+1 in function call. I have trouble using variables
EDIT: Problem solved. It was my reading that was incorrect, not the SQL :p
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
Edit : The bug that caused this problem has been fixed. The @version tag
EDIT: I have realized the source of my problem. I only have count information
My problem: I have Ido-mode enabled and I want to edit (for example) a
THIRD EDIT: I now believe that this problem is due to a SOAP version
PROBLEM SOLVED: I was overlooking a very simple issue, and that is that this
[EDIT]Problem solved, I found the leak. Thank you very much. I'm running a scheduling

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.