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

前端 未结 5 399
没有蜡笔的小新
没有蜡笔的小新 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:03

    casting to double should fix the error.

    double returnVal =  (double ) (currPixel) / (modifier) * newValue;
    

    see type casting rules typecasting rules in c.

提交回复
热议问题