Doing Maths in Hex

Thierry Douez th.douez at gmail.com
Tue May 3 13:45:11 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
>
> Well done, Thierry!
>
> Devin
>

​Thanks Devin :)

and before the next cquestion will arises:
​

put addHexy( "20F", "4CD", "10", "3AB")

function addHexy
   local T
   repeat with i = 1 to paramCount()
      add baseConvert(  param( i) ,16,10) to T
   end repeat
   return baseconvert( T, 10, 16)
end addHexy


​Thierry
​

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



More information about the use-livecode mailing list