I have noticed that the % operator does only work on int and that pose a litte problem for me.
I have a double containing a large number of milliseconds. and i would like to break it down into three INT variables (minutes,seconds,ms)
i have taken out the part that is bothering me right now. the ms=totaltime%1000; tosses an error, as you cant use % on a double. is there some way to do this? do anyone has another easy solution to this problem?
double totaltime=9234843; //the time in milliseconds
int minutes;
int seconds;
int ms;
ms=totaltime%1000;
Sorry to bother you, i found out a way to solve my problem
I did it the other way around instead, and that seems to work fine.
You could easily add hours to this equation too if necessary.
maybe someone else will have use of this solution.. when using millis() to count how long time that has elapsed, you often end up with alot of millis that you would like to show in a more suitable fashion.
It should work with the unsigned long. It certainly will not work with the float or double types. I can't check right now because my test Arduino is running a wifi server test sketch.
% calculates the remainder when one integer is divided by another.
An int is not the only type of integer type. A long, signed or unsigned, is an integer too, so % will work with it.