Doing Maths in Hex

Thierry Douez th.douez at gmail.com
Tue May 3 13:13:55 EDT 2016


and with a bit of factoring...

   put addHex( "20F", "4CD")


function addHex v1, v2
   local d1, d2
   put baseConvert( v1,16,10)  into d1
   put baseConvert( v2,16,10)  into d2
   return baseconvert( d1 + d2, 10, 16)
end addHex

Thierry



2016-05-03 18:13 GMT+02:00 Devin Asay <devin_asay at byu.edu>:

>
> > On May 3, 2016, at 9:32 AM, dunbarx <dunbarx at aol.com> wrote:
> >
> > Richmond.
> >
> > LC cannot add "20F" to "4CD". You need to use "baseConvert". Not onerous
> at
> > all, really.
>
> put baseConvert(baseConvert("20F",16,10) + baseConvert("4CD",16,10),10,16)
>
> devin
>
>

-- 
------------------------------------------------
Thierry Douez - http://sunny-tdz.com



More information about the Use-livecode mailing list