Ask Your Question
0

Test number for 2^x in Calc [closed]

asked 2013-04-03 19:56:10 +0200

rcw gravatar image

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 flag offensive 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

Comments

1

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

JohnSUN gravatar imageJohnSUN ( 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.

rcw gravatar imagercw ( 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 )

JohnSUN gravatar imageJohnSUN ( 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.

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

5 Answers

Sort by » oldest newest most voted
1

answered 2013-04-05 20:47:45 +0200

rcw gravatar image

updated 2014-05-24 23:50:18 +0200

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.

edit flag offensive delete link more

Comments

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!

qubit gravatar imagequbit ( 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.

rcw gravatar imagercw ( 2013-04-07 22:12:48 +0200 )edit
1

answered 2013-04-08 03:40:24 +0200

ROSt52 gravatar image

updated 2013-04-08 11:06:56 +0200

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:

image description

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

This is done with Windows version.

edit flag offensive delete link more

Comments

An enhancement request is filed. Please feel free to add comments to enable better judgment. https://bugs.freedesktop.org/show_bug.cgi?id=63287

ROSt52 gravatar imageROSt52 ( 2013-04-09 06:32:28 +0200 )edit
1

answered 2014-05-26 09:33:01 +0200

Lupp gravatar image

updated 2014-05-26 11:58:20 +0200

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.

edit flag offensive delete link more
0

answered 2013-04-03 21:42:49 +0200

m.a.riosv gravatar image

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

edit flag offensive delete link more

Comments

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.

rcw gravatar imagercw ( 2013-04-03 23:11:37 +0200 )edit
0

answered 2013-04-04 03:24:50 +0200

m.a.riosv gravatar image

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))))

image description

edit flag offensive delete link more

Comments

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.

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

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

m.a.riosv gravatar imagem.a.riosv ( 2013-04-05 03:42:26 +0200 )edit

Yes, Thank you very much. Dick

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

Question Tools

Stats

Asked: 2013-04-03 19:56:10 +0200

Seen: 510 times

Last updated: May 26 '14