I think this will do it: ASSERT("840003123456770"=Get_value ("02ABC877FAFB0200"))
using primary school maths only... -- C_TEXT($1;$0) Case of : (Count parameters=1) C_TEXT(hex;$e;$total) C_LONGINT($i) $hex:=$1 For ($i;1;Length($hex);2) //hex byte code to integer string $byte:=Substring($hex;$i;2) $code:="<!--#4deval 0x"+$byte+"-->" PROCESS 4D TAGS($code;$code) If ($i=1) $value:=$code $e:="1" Else //exp beyond 256^5 is a bit hazy, might as well do it using text EXECUTE METHOD(Current method name;$e;$e;"256";"*") //base-10 text multiplication EXECUTE METHOD(Current method name;$value;$code;$e;"*") End if //base-10 text addition EXECUTE METHOD(Current method name;$total;$total;$value;"+") End for $0:=$total : (Count parameters=3) C_TEXT($a;$b;$r) $a:=String($1) $b:=String($2) $operand:=$3 If ($a="") $a:="0" End if If ($b="") $b:="0" End if //no checking for non-numbers, negative numbers, e C_LONGINT($lena;$lenb) $lena:=Length($a) $lenb:=Length($b) C_LONGINT($c;$d;$e;$f;$m1;$m2;$m3) ARRAY LONGINT($mm;0) Case of : ($operand="*") $d:=0 For ($x;$lena;1;-1) $c:=1 For ($y;$lenb;1;-1) $m:=Num($a[[$x]])*Num($b[[$y]]) $e:=$m%10 $f:=$m\10 If (($c+$d+2)>Size of array($mm)) ARRAY LONGINT($mm;$c+$d+2) End if $m1:=$mm{$c+$d}+$e $m2:=$mm{$c+$d+1}+$f+($m1\10) $m3:=$mm{$c+$d+2}+($m2\10) $mm{$c+$d}:=$m1%10 $mm{$c+$d+1}:=$m2%10 $mm{$c+$d+2}:=$m3 $c:=$c+1 End for $d:=$d+1 End for : ($operand="+") $len:=Choose($lena>$lenb;$lena;$lenb) $a:=Substring(("0"*$len)+$a;$lena+1) $b:=Substring(("0"*$len)+$b;$lenb+1) $c:=1 For ($x;$len;1;-1) $m:=Num($a[[$x]])+Num($b[[$x]]) $e:=$m%10 $f:=$m\10 If (($c+2)>Size of array($mm)) ARRAY LONGINT($mm;$c+2) End if $m1:=$mm{$c}+$e $m2:=$mm{$c+1}+$f+($m1\10) $m3:=$mm{$c+2}+($m2\10) $mm{$c}:=$m1%10 $mm{$c+1}:=$m2%10 $mm{$c+2}:=$m3 $c:=$c+1 End for End case //filter preceeding zeros and stringify $r:="0" C_LONGINT($i;$len) $len:=Size of array($mm) For ($i;$len;1;-1) If ($r="0") $r:="" End if $r:=$r+String($mm{$i}) End for $0:=$r End case ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************