Results 1 to 5 of 5

Thread: Libreoffice calc - leading zeros with dec2bin

  1. #1
    Join Date
    Nov 2011
    Beans
    438
    Distro
    Ubuntu 14.04 Trusty Tahr

    Libreoffice calc - leading zeros with dec2bin

    I'm converting a ten base number to two base with =dec2bin() but how do I add leading zeros so I could end up with a distinct n bit number? Like, 0010 instead of 10. Goal is to then merge two of those into an eight bit number, so that 0010 and 0100 would make 00100100, now I'm getting just 100100 which isn't quite the same thing :/

  2. #2
    Join Date
    Jul 2009
    Location
    Austin, Texas, USA
    Beans
    436

    Re: Libreoffice calc - leading zeros with dec2bin

    You may in fact be getting the eight-bit number you seek; your difficulty may be simply a matter of the format of the cell(s) containing the result.

    Try this: In Libre Office, click on Format -> Cells -> Numbers, and then ensure that the "Leading zeroes" option is set to 8.

  3. #3
    Join Date
    Nov 2011
    Beans
    438
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Libreoffice calc - leading zeros with dec2bin

    Increasing number of leading zeroes in cell formatting does nothing for a cell with =DEC2BIN() in it, it seems. I also tried \0000 in the formatting field but that doesn't do anything either :/

    That is, both methods give me 0010 if I've typed 10 into that cell, or used =() to a cell with ten base 10 in it, but when I have =DEC2BIN() in either cell I just get 10.

  4. #4
    Join Date
    Apr 2012
    Beans
    7,003

    Re: Libreoffice calc - leading zeros with dec2bin

    There is a second argument to the dec2bin function that sets the number of digits to display e.g.

    Code:
    dec2bin(A1,8)
    Screenshot from 2013-12-22 08:43:09.png

  5. #5
    Join Date
    Nov 2011
    Beans
    438
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Libreoffice calc - leading zeros with dec2bin

    Yay, that does exactly what I wanted =)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •