Repeat for email. On Friday, 11 October 2019 15:45:12 UTC+2, @TiddlyTweeter wrote: > > In another thread Mark S. presented a magic macro to convert from decimal > to other bases. > > I think its a rather marvellous bit of coding.* I have no idea how it > works*, but it does work well. > > Its a VERY good illustration of using TW macros to achieve something > specific in a direct very useful, economic way. > > This is my slight cosmetic re-order of it for converting decimal to > base-2 through to base-36. > > \define base-convertor(num,base,result:"") > <$list filter="[<__num__>remainder<__base__>add[1]]" variable=remidx> > <$list filter="[<__num__>divide<__base__>trunc[]]" variable=num> > <$list filter="[enlist<syms>nth<remidx>addsuffix<__result__>]" > variable="result"> > <$list filter="[<num>!regexp[^0$]]" emptyMessage=<<result>>> > <$macrocall $name=base-convertor num=<<num>> base="$base$" > result=<<result>>/> > </$list> > </$list> > </$list> > </$list> > \end > > \define re-base(base,num) > <$vars > syms="0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X > Y Z" > > > <<base-convertor $num$ $base$>> > </$vars> > \end > > Syntax: re-base "base" "decimal inut" > Supports base-2 to base-36. > > ;Examples > :1025 decimal = <<re-base 2 90000000000000000000000000000000000000000000>> > base 2 > :1025 decimal = <<re-base 10 1025>> base 10 > :1025 decimal = <<re-base 16 1025>> base 16 > :1025 decimal = <<re-base 26 1025>> base 26 > :1025 decimal = <<re-base 27 1025>> base 27 > :1025 decimal = <<re-base 36 1025>> base 36 > > > Partly Mark responded because I needed that tool to properly document > non-Westren body-part counting systems. > As soon as I had it up I wrote a note for a culture that counts in > base-27. I could not have done it without it. > > Thanks Mark! > > [image: Annotation 2019-10-11 145847.jpg] > > > Best wishes > TT >
-- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/152f7069-7afd-4b1e-9915-759c1b6204e3%40googlegroups.com.

