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,911
  • 3
  • 42
  • 59
Vijay13
  • 525
  • 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,870
  • 3
  • 19
  • 31
1

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

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