C++, my double or int value is always 0

前端 未结 5 446
没有蜡笔的小新
没有蜡笔的小新 2021-01-25 14:32

I\'m fairly new to C++ and I\'m experiencing some strange behaviour from a percentage increase method I am writing for some image editing software.

What I want to do is

5条回答
  •  不要未来只要你来
    2021-01-25 15:19

    As long as all values are in a range, let me say, less than 1000 and greater (or equal) than 0, which is common on colour values, do something like

    int returnVal = (currPixel * newValue) / modifier
    

    No need for doubles; it will even speed up the code. Needless to say, modifiershould not be zero.

提交回复
热议问题