Mark - you're adding 10 (decimal) somewhere. FFFF -> 65545 0000 -> 10
On Wednesday, December 2, 2020 at 3:41:11 PM UTC-6 Mark S. wrote: > Here's my first attempt. It uses the 5.1.23 search-replace filter > operator. It requires the input to be padded to 4 bytes. > > Now that I've done it, I realize it could probably be written with a > recursive loop and be open ended (not needing to be padded). > > \define hex2dec2(hex) > <$vars myhex=<<__hex__>> > myfilter="[split[]nth<place>search-replace:g[A],[10]search-replace:g[B],[11]search-replace:g[C],[12]search-replace:g[D],[13]search-replace:g[E],[14]search-replace:g[F],[15]]"> > <$list filter="1 2 3 4" variable="place"><<place>> > <$list filter="[<myhex>subfilter<myfilter>] > [<place>compare:number:eq[1]then[4096]else[1]] [<myhex>subfilter<myfilter>] > [<place>compare:number:eq[2]then[256]else[1]] [<myhex>subfilter<myfilter>] > [<place>compare:number:eq[3]then[16]else[1]]+[product[]]"/> > </$list> > </$vars> > \end > \define hex2dec(hex) > <$wikify text="<<hex2dec2 $hex$>>" name=dec> > <$list filter="[enlist<dec>sum[]]"/> > </$wikify> > \end > <<hex2dec EA0E>> > > On Wednesday, December 2, 2020 at 3:34:02 AM UTC-8 TW Tones wrote: > >> Mark, >> >> On this occasion I need to convert a 4 digit Hex to a decimal, so that I >> can use it in the range widget, because we cant generate a range of hex >> numbers. >> >>> >>>> -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/0011fd81-7d7b-431c-876d-ce7fb879d563n%40googlegroups.com.