Leading Zeros in Binary

Alex Tweedly alex at tweedly.net
Thu Nov 17 16:03:52 EST 2005


Camm29 wrote:

>Help !!!! Please
>
>When using baseConvert ("00FFFFFF" , 16 , 2) 
>
>it returns 111111111111111111111111 
>
>This is correct but i wish to keep the leading zeros for bit manipulation
>
>so i need the result to be ,
>00000000111111111111111111111111
>
>  
>
You can't do it directly in baseconvert (AFAIK), but you can use 
"format" to add leading 0s

put format("%032s", baseconvert("00FFFFFF", 16, 2))
    gives
00000000111111111111111111111111

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.2/170 - Release Date: 15/11/2005




More information about the use-livecode mailing list