Harvard Mark 1 decimal digits - decimal

The Harvard Mark 1 computer has 72 words of 23 decimal digits each, does this mean that each word contains 23 binary digits that represent 1 decimal digit?

No, at least the registers of that computer really stored decimal digits. It was electromechanical, the storage may have involved wheels.
This has some pictures in it:
http://www.bitsavers.org/pdf/harvard/MarkI_operMan_1946.pdf

Related

Check if digits in a number can be rearranged to form a fibonacci number

This question is asked in a programming contest. I couldn't find any way other than generating all permutations. But the number of digits is upto 15 and no of permutations (15!) is very large. Is there any other way?
I know that if (5*N^2 + 4) or (5*N^2 - 4) is a perfect square, n is fibonacci.
You don't need to generate all permutations. Generate the fibonacci numbers of desired length (which will be less than 74 numbers, because 73rd fib. number is the highest with 15 digits) and then just check for those few whether they can be "constructed" from digits in the given number.

Numbers stored as text - when converted to numbers, digits disappear

I have a column of data with numbers stored in text.
The numbers look like this: 735999114002665788
If I select any cell in this column and refer to it with the function =value(), the number shows up as 735999114002665000.
As you can see the last three digits are 0. This happens all the time with numbers this long - but NOT with numbers containing less digits.
Am I trying to convert a number that's too large or what's up? Please help! I've tried every form of text-to-number method with identical results :(
Excel's number precision is 15 digits, which is why you're losing the last three digits when converting your 18 character string
https://support.office.com/en-us/article/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3#ID0EBABAAA=Excel_2016-2013
Excel only allows a maximum of 15 digits of precision for each number in a cell. The reason why this number:
735999114002665788
becomes this:
735999114002665000
is because Excel is choosing to retain the 15 most significant digits in the number. This means that the ones, tens, and thousands digits are being tossed out.
By the way, this question has been asked before on SuperUser, and you can read about it here:
https://superuser.com/questions/437764/why-is-excel-truncating-my-16-digit-numbers

bin2dec for numbers longer than 10 bits in excel

I have an excel with 28 position binary numbers. I need to convert them to decimal numbers, but function bin2dec don't work with numbers longer than 10 bits. Can anyone help me with this?
Use the following formula to mimic a BIN2DEC function that coverts larger than 10 bits.
=SUMPRODUCT(--MID(A2,LEN(A2)+1-ROW(INDIRECT("1:"&LEN(A2))),1),(2^(ROW(INDIRECT("1:"&LEN(A2)))-1)))
Remember that Excel has a numerical precision of 15 digits. If you want 28 digits, format the cell as Text or preface the string of digits with a single tick (e.g. ') as a PrefixCharacter property.
   
I brute forced it with the math, may be inelegant, but for a 16 bit number where leading 0's will be displayed this works and can easily be adapted to longer strings
This works well if you are working with fixed length words, like verifying values in memory, BIT registers, etc.
16 bit
=BIN2DEC(LEFT(R5,8))*2^8+BIN2DEC(RIGHT(R5,8))
32 bit could be
=BIN2DEC(MID(R10,1,8))*2^24+BIN2DEC(MID(R10,9,8))*2^16+BIN2DEC(MID(R10,17,8))*2^8+BIN2DEC(MID(R10,25,8))
Again, this works if you have a fixed length input, leading zeros are displayed.

Coverting strings to decimal with a radix

I'm just getting into Empire of Code and I've come across a problem that I don't understand at all. Could someone do an ELI5 for this? I'm not sure even where to start with making the function. This is the problem:
You are given a positive number as a string along with the radix for it. Your function should convert it into decimal form. The radix is less than 37 and greater than 1. The task uses digits and the letters A-Z for the strings.
Watch out for cases when the number cannot be converted. For example: "1A" cannot be converted with radix 9. For these cases your function should return -1.
Input: Two arguments. A number as string and a radix as an integer.
Output: The converted number as an integer.
Example:
convert("AF", 16) == 175
convert("101", 2) == 5
convert("101", 5) == 26
convert("Z", 36) == 35
convert("AB", 10) == -1
What exactly is it asking? I don't know enough about number bases to have even the slightest grip on this.
Our number system is base 10. There are 10 possible digits you can use to represent numbers, 0-9. Once you get to 9, you need an extra digit to represent a larger number (10).
Other systems are, of course, possible. Some famous ones:
Base 2 ("binary"): Only digits are 0 and 1. Once you get to 2 you need more digits (10).
Base 8 ("octal"): Only digits are 0-7. Once you get to 8 you need more digits (10).
There are also bases higher than 10. Because we don't have numbers for these normally we pull in letters to substitute. The most common one here is base 16 (aka "hexadecimal"), which uses 0-9 followed by A-F, where A=10, B=11, and so on out to F=15. Once you get to 16, you need more digits (10).
When we say "Base N", the "N" there is the radix (technical term from mathematics). You need the radix for cases where there is ambiguity. For example, I just showed you four different numbers that '10' can represent, depending on the base you're working in. (In fact, you may have noticed that if you follow the normal conventions as I have here, '10' always represents the number corresponding to the base you're working in: 2 in binary, 8 in octal, 16 in hex, etc.)
You can also make some inferences based on having too many digits. For example, "2" is not a valid number in base 2 (binary), because the only valid digits are 0 and 1. Likewise, "1A" cannot be represented in base 9 because necessarily the only valid digits there would be 0-8. The "A" doesn't become necessary until you hit at least base 11.
Hope that helps.
You can use the int() to solve this too. Looks like python has the in-built to convert str to base.
Convert hex string to int in Python

associativity of operations regarding floating points

I am trying to understand tthe associativity of operations when it comes to floating points.
In the lecture notes i have, the following is stated:
"suppose floating-point values store seven digit of accuracy.
Considee the problem of adding 11 numbers together, where one of the numbers is 10^7 and the other ten are 1.
If the small numbers (the 1s) are each added to the large number, one at a time, there is no effect on that number, because the small numbers occur in the eighth digit of the large number ". So here I understood that the result is 1,000,001.
"however, if the small numbers are first added together and the result is added to the large number, the result is a seven-digit accurancy 1.000001 * 10^7"
But both approaches seemed the same to me: we are adding the 10 numbers to the larger number.
Can someone please clarify this problem ?
Thank you
Let's go over the first method first. When the small numbers are added one by one to the large number, the following will happen ten times:
10,000,000 + 1 = 10,000,001
However since the floating-point values store only seven digits of accuracy this last digit, the eight digit, will be rounded in the seventh digit to zero. This operation will happen 10 times, and so the value will remain 10,000,000.
Next let's go over the second method. The 10 number 1's are added together first and so this will sum up to 10. When this is added to 10^7 the following will happen:
10,000,000 + 10 = 10,000,010
Since the floating-point values store seven digits of accuracy this number will remain!

Resources