Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I do AND operation on two binary numbers in MS Excel?
I want to do AND say to the following:
00101001 AND to 10001001 and should get the following answer: 00001001 What function should I use in MS Excel to get this? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I do AND operation on two binary numbers in MS Excel?
All you need to do is to put the zeros and ones in separate cells. Then the
AND function will work: =--AND(A1,A2) -- Gary's Student "Zuke" wrote: I want to do AND say to the following: 00101001 AND to 10001001 and should get the following answer: 00001001 What function should I use in MS Excel to get this? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I do AND operation on two binary numbers in MS Excel?
Not sure what operation you want to do with these numbers. Converted to
decimal you have asked that 41 AND 137 = 9 If you go to Tools/Add-ins and check Analysis ToolPak, you will get some additional math functions that work with Binary, Octal and Hexadecimal numbers. Mike F "Zuke" wrote in message ... I want to do AND say to the following: 00101001 AND to 10001001 and should get the following answer: 00001001 What function should I use in MS Excel to get this? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I do AND operation on two binary numbers in MS Excel?
On Wed, 11 Jan 2006 14:50:02 -0800, "Zuke"
wrote: I want to do AND say to the following: 00101001 AND to 10001001 and should get the following answer: 00001001 What function should I use in MS Excel to get this? I don't know how to do it with a worksheet function. But you can write a UDF (user-defined function) in VBA to do that. <alt-F11 opens the VB Editor. Ensure your project is highlighted in the Project Explorer window. Then Insert/Module and paste the code below into the window that opens. You can use the function by typing: =BinaryAND(00101001,00001001) or by placing those numbers into cells, and using the cell references. The AND function in VBA is supposed to do something similar, but I cannot seem to get it to work properly at this time. ================================ Option Explicit Function BinaryAND(n1, n2) As String Dim i As Long Dim l As Long Dim b1 As String, b2 As String Dim Fmt As String Dim temp As String l = Application.WorksheetFunction.Max(Len(n1), Len(n2)) Fmt = Application.WorksheetFunction.Rept("0", l) b1 = Format(n1, Fmt) b2 = Format(n2, Fmt) For i = 1 To l temp = temp & Mid(b1, i, 1) * Mid(b2, i, 1) Next i BinaryAND = temp End Function =================================== --ron |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I do AND operation on two binary numbers in MS Excel?
Zuke,
Not a complete solution yet, but the ArrayFormula "{=F11+F12}" returns 10102002, so with a couple of SUBSTITUTEs you get the answer. There probably a better way ! NickHK "Zuke" wrote in message ... I want to do AND say to the following: 00101001 AND to 10001001 and should get the following answer: 00001001 What function should I use in MS Excel to get this? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I do AND operation on two binary numbers in MS Excel?
Reading this again, am I stupid, or does this work ?
(Although a simple addition suffices) NickHK "NickHK" wrote in message ... Zuke, Not a complete solution yet, but the ArrayFormula "{=F11+F12}" returns 10102002, so with a couple of SUBSTITUTEs you get the answer. There probably a better way ! NickHK "Zuke" wrote in message ... I want to do AND say to the following: 00101001 AND to 10001001 and should get the following answer: 00001001 What function should I use in MS Excel to get this? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I do AND operation on two binary numbers in MS Excel?
If you set a vba library reference to "atpvbaen.xls", then the following
returns the string "1001" Sub Demo() Dim s1, s2, Answer s1 = "00101001" s2 = "10001001" ' Returns 1001 Answer = Dec2Bin(Bin2Dec(s1) And Bin2Dec(s2)) End Sub HTH -- Dana DeLouis Win XP & Office 2003 "Zuke" wrote in message ... I want to do AND say to the following: 00101001 AND to 10001001 and should get the following answer: 00001001 What function should I use in MS Excel to get this? |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I do AND operation on two binary numbers in MS Excel?
should get the following answer: 00001001
Oops. For leading zero's, a slight change... Sub Demo() Dim s1, s2, Answer s1 = "00101001" s2 = "10001001" ' Returns 00001001 Answer = Dec2Bin(Bin2Dec(s1) And Bin2Dec(s2), 8) End Sub -- Dana DeLouis Win XP & Office 2003 <snip |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Binary Numbers | Excel Discussion (Misc queries) | |||
EXCEL: How to present 8-bits binary numbers | Excel Discussion (Misc queries) | |||
large binary numbers | Excel Worksheet Functions | |||
Binary numbers longer than 10 characters | Excel Programming | |||
Binary Numbers longer than 10 characters | Excel Worksheet Functions |