negative numbers in RevealWidget comparison not ... mathematically accurate?

Skip to first unread message

Nov 21, 2021, 9:45:58 PM11/21/21
to TiddlyWiki
I might be missing something, but given this demo here:

  0 gt -5: <$reveal type="gt" default=0  text=-5>yes</$reveal><br />
-1 gt -5: <$reveal type="gt" default=-1 text=-5>yes

</$reveal><br />
-5 gt -1: <$reveal type="gt" default=-5 text=-1>yes
</$reveal><br />
 0 lt -5: <$reveal type="lt" default=0  text=-5>yes
</$reveal><br />
-5 lt  0: <$reveal type="lt" default=-5 text=0>yes
</$reveal><br />
-1 lt -5: <$reveal type="lt" default=-1 text=-5>yes
</$reveal><br />
-5 lt -1: <$reveal type="lt" default=-5 text=-1>yes</$reveal>

I get the following output:

 0 gt -5: yes
-1 gt -5:
-5 gt -1: yes  <-- -5 is less than -1, not greater
 0 lt -5:
-5 lt  0: yes
-1 lt -5: yes  <-- -1 is greater than -5, not less
-5 lt -1:

Is this a known issue?

Charlie Veniot

Nov 21, 2021, 10:56:53 PM11/21/21
to TiddlyWiki

I think gt and lt in reveal widgets, only works with positive integers.

Jeremy Ruston

Nov 22, 2021, 4:42:36 AM11/22/21
to TiddlyWiki
The issue here is that the reveal widget only performs string comparisons, and doesn't understand numbers at all.

More complex comparisons including numeric operations can be performed with the list widget and filter.

Best wishes


Nov 22, 2021, 7:35:38 AM11/22/21
to TiddlyWiki
That do make sense. ListWidget will work for what I am doing as well... actually, not sure why I went with RevealWidget as I am using ListWidget for other comparisons elsewhere ...


Thanks for the answers!

TW Tones

Nov 22, 2021, 9:51:45 PM11/22/21
to TiddlyWiki
My Guess is its only problem is with Negatives as charlie suggested;

1 lt 10: <$reveal type="lt" default=1 text=10>yes

So adding to the documentation "compares positive numbers only" is sufficient to correct it, until perhaps it is improved!

It should be quite easy to swap the negatives for positives to make it work, even if you need to convert them for display as negative numbers, and reverse the conditions eg lt for gt.

Reply all
Reply to author
0 new messages