Search notes:

Excel conversion functions (x2y)

Excel has some conversion functions whose name generally is x2y, for example dec2bin which converts a decimal number to its binary representation.

Demonstration of dec2bin

The following example tries to demonstrate dec2bin.
Unfortunately, as the second row shows, dec2bin cannot convert a number greater then 511, it causes a #NUM! cell error.
Therefore, the third row concatenates two results of dec2bin with the concatenation operator &.
option explicit

sub main() ' {

    cells(1, 1) = 500
    cells(1, 2).formulaR1C1 = "=dec2bin(rc[-1])"

    cells(2, 1) = 512
    cells(2, 2).formulaR1C1 = "=dec2bin(rc[-1])"

    cells(3, 1) = 123456
    cells(3, 2).formulaR1C1 = "=dec2bin(int(rc[-1]/512), 9) & " & _
                               "dec2bin(mod(rc[-1],512), 9)"

    with columns(2)

       .horizontalAlignment = xlRight
       .select
        with selection.font
             .name = "Courier New"
             .bold = true
        end with

       .autoFit
    end with

    cells(5, 5).select

end sub ' }
Github repository about-Excel, path: /functions/x2y/dec2bin.bas

Misc

In German versions of Excel, dec2bin is called dezinbin

See also

Other conversion functions
Excel functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1758201508, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Excel/functions/x2y/index(91): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78