PureBytes Links
Trading Reference Links
|
Hi Dan,
I have just written something that should do what you want.
Enjoy.
/* Bin to Dec conversion by OzFalcon */
bin = 00110;
binstr = "0000000"; /* Make sure binstr is a STRING */
binstr = binstr + bin; /* Pad out first bits */
bindec = 0; z=0;
binstr = StrRight(binstr,8); /* Make binstr correct lenght */
for (i = 1 ; i <= 256 ; i=i*2)
{
z++; x = StrRight(binstr,z); y = StrLeft(x,1); /* extract bit */
if (y == "1") bindec = bindec + i; /* Add value of bit if on */
printf ("This is bit:%g " , z);
printf ("(y = " + y + ") (val = %g)\n",i);
}
printf ("Total:%g\n",bindec);
danandsara95 wrote:
>
> Anyone know how to convert a binary number to decimal in AFL (i.e. 110
> binary == 6 decimal)
>
> Thanks,
>
> Dan
>
>
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.28/605 - Release Date: 12/27/2006 12:21 PM
|