1

I have following code in my qt program :

        lambda = lambda % 360.0  + dphi ;

And I am getting following error while compiling: /home/vijay13/Downloads/app/app/skyobjects/ksmoon.cpp:389: error: invalid operands of types 'double' and 'double' to binary 'operator%'

Can someone please help me get modulus of given double in qt/c++ ?

goji
  • 6,631
  • 3
  • 37
  • 57
Vijay13
  • 465
  • 2
  • 8
  • 18

2 Answers2

4

This has nothing to with Qt. The fact of the matter is that the % operator can't be applied to double.

For more information, and a possible solution, see: Can't use modulus on doubles?

Community
  • 1
  • 1
CmdrMoozy
  • 3,730
  • 18
  • 28
1

This is because built in % is for integers. You can use fmod from cmath library for non-integers.

tomi.lee.jones
  • 1,523
  • 1
  • 15
  • 22