Hi,
A useful operator is the modulus (in many programming language is that %
) to calculate the remainder of a integer division.
E.g.:
$#Db#%2==1?100:0$
-or-
$mod(#Db#,2)==1?100:0$
Funny enough, the %
-operator works in the online creator, but doesn’t work in the preview or on the watch.
Thx,
Svensei38
Has this changed since?
I have the ‘%
’ operator working in both preview and on my Samsung Gear Sport.
We’ve tested % on the creator, android wear, and Tizen and it seems to work as expected. Let us know if you’re seeing anything different and we’ll investigate!
It is working for me.
I did try using other mathematics before I realised you supported it. (It was not initially in online documentation).
Hi,
I’ve just finished testing.
This works:
(#Ds#%2)*100
But this doesn’t work:
$#Ds#%2=1?100:0$
$#Ds#%5>1?100:0$
Tested on a Huawei Watch 2 Classic (Android Wear 2).
Having modulus would be a great added value in conditionals.
Greetz,
Svensei38
Can you try putting the modulus between parenthesis in your conditional? i.e.
$(#Ds#%2)=1?100:0$
Hi,
I did that in the same test.
I’ve tested:
$#Ds#%2=1?100:0$
$(#Ds#%2)=1?100:0$
$((#Ds#%2)=1)?100:0$
None of the above worked on my watch.
Kind regards,
Svensei38
Just quickly tested/verified:
(3%2)
(4%2)
(5%2)
$(#Ds#%2)=1?true:false$
$#Ds#%2=1?1:0$
$(#Ds#%2)=1?1:0$
$#Ds#%2=1?true:false$
on build 4.3.6.6 .
I am using ‘%’ quite extensively on my ‘moon phase’ test face and various gauges, all with no apparent issues.
Hi @Svensei38 - our test team confirmed $(#Ds#%2)=1?100:0$ works for them on all platforms (Wear, Tizen, Web)
Hi,
I can confirm a successful test now .
I’ve tested this watchface:
This operator will save me a lot of work.
Thanks for all the help.
Greetz,
Svensei38