# Test number for 2^x in Calc [closed]

In many languages you can test (2^x)==y to see if y contains a 4 for example. Or you can pull out a 0 or 4 with (2^2)&y.

Can you help me find this functionality?

Thanks, Dick

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Alex Kemp close date 2016-02-23 21:39:28.804579

1

Do you mean functions BITAND() and BITOR()?

( 2013-04-04 09:03:37 +0200 )edit

Thanks for your time. Yes this sounds just right. However BITAND() is not listed in functions and BITAND() returns #NAME? for me in LibreOffice 3.4.3 OOO340m1 (Build:302). Is there an extension to download? Thanks again.

( 2013-04-05 01:29:26 +0200 )edit

Yes, I didn't found a description of these functions in the Help too. I stumbled upon them in LibreOffice 4.0.1 (There are description of these functions is in the help of HelpPack )

( 2013-04-05 08:46:42 +0200 )edit

I installed LibreOffice Version 3.6.5.2 as itsGetting started doc stated it had added BITx as declared in the ODF 1.2 specification." Tested BITAND() and it works fine. However the new LibreOffice download seemed to require Torrent if I didn't want to build my own downloader. I DID NOT LIKE THE EXPERIENCE OF GETTING RID OF uTORRENT AT ALL! If you prefer to avoid that the text solution works, otherwise BITAND() is cleaner. Thanks to JohnSUN and mariosv.

( 2013-04-05 18:22:38 +0200 )edit

Sort by » oldest newest most voted

Use BITAND() to test for binary values. Your version of LibreOffice must be 3.6 or greater. TRUE=BITAND(4,20) - from JohnSUN Previous to version 3.6 use this text based test =NOT(ISERROR(SEARCH(SUBSTITUTE(BASE(4;2);"0";".")&"$";BASE(109;2)))) using =IF(B3;Formula;0) to prevent a search for 0 returning a TRUE - from mariosv Comment: I installed LibreOffice Version 3.6.5.2 as itsGetting started doc stated it had added BITx as declared in the ODF 1.2 specification." The new LibreOffice download seemed to require Torrent if I didn't want to build my own downloader. I DID NOT LIKE THE EXPERIENCE OF GETTING RID OF uTORRENT AT ALL! I recently (Version 4.2.0.4) tested =BITAND($B14,4), =BITAND($G17,2^2), and =IF(BITAND($L17,2^2),1,0) which returned 4, 4, and 1. All work depending on the form of the test and desired answer. Thanks to JohnSUN and mariosv.

more

Hi @rcw,

I'm not sure what platform you're using, but you should be able to grab the latest build of LibreOffice on the download page without using bittorrent. Please try clicking on the text that reads Main installer, or (if you'd like to choose a different language or OS) click on Change System, Version or Language.

Thanks!

( 2013-04-06 06:51:23 +0200 )edit

Looking at the the download page I now see that Main Installer, torrent, and Info are different choices. As they are all inside a big green box I did not notice the different links until you said I should be able to not use torrent. Sigh. Thanks for your time.

( 2013-04-07 22:12:48 +0200 )edit

As "rcw" recently updated this post: If someone still is using old versions of Calc not containing the bit operation functions for some reason: =ISODD(QUOTIENT({ValueToTest};{PowerOf2})) is a compact alternative to the formerly suggested text oriented solutions.

Using versions containing the bit functions the formula

=QUOTIENT({ValueToTest};{Base}^{Exponent})-QUOTIENT(CURRENT();{Base}) * {Base} can still be used where the base for whose powers should be tested is not 2 but another integer number.

Sorry, the last formula was erroneous in the first post of this answer. It was rectified by editing.

more

As we have 2 topics under this question my answer concerns @rcw's comment

I DID NOT LIKE THE EXPERIENCE OF GETTING RID OF uTORRENT AT ALL!

I feel that the current button to download LibO or LibO help files is a bit confusing. I also was once confronted with a torrent file and found later accidentally that the download button contains 2 versions:

Depending on where you click you a msi-file or torrent-file download starts.

This is done with Windows version.

more

( 2013-04-09 06:32:28 +0200 )edit

Only one equal for comparisons in calc.
You can do:
=(2^2)=4

more

2^2+2^4=20. I was looking for the test: Does number (example 20) contain a 4? In binary, 00100+10000=10100. I am trying to test for the binary position. This can be used for a mask or as a flag.

( 2013-04-03 23:11:37 +0200 )edit

Forgive me rcw, I have misunderstood your question.

Next screenshot shows one way to find if a binary is inside other, using the SEARCH() function which allow regular expression, substituting the zeroes with point (any character) adding the "$" (to find at the end). =NOT(ISERROR(SEARCH(SUBSTITUTE(BASE(4;2);"0";".")&"$";BASE(109;2))))

more

Thanks for your time. This text solution works for all but case "0" where it always returns True. If I can't get a math method running this will work. Thanks again.

( 2013-04-05 01:24:42 +0200 )edit

A simple solution: =IF(B3;Formula;0), can solve the 0 issue.

( 2013-04-05 03:42:26 +0200 )edit

Yes, Thank you very much. Dick

( 2013-04-05 04:44:08 +0200 )edit