Tag Info

Hot answers tagged

56

Of course it is possible, both theoretically and practically. Theoretically, there are two classes of alternatives: digital number systems with a base other than 2 (in fact, the decimal system as we know it is one such system); and non-digital number systems. Mathematically speaking, we're talking about discrete vs. continuous domains. In practice, both ...


31

A lot of really early work was done with 5-bit baudot codes, but those quickly became quite limiting (only 32 possible characters, so basically only upper-case letters, and a few punctuation marks, but not enough "space" for digits). From there, quite a few machines went to 6-bit characters. This was still pretty inadequate though -- if you wanted upper- ...


24

Your argumentation against floating point numbers is very fragile, probably because of naivety. (No offense here, I find your question is actually very interesting, I hope my answer will also be.) A classic argument is that floats provide a greater range, but high precision integers can meet this challenge now. For example: with modern 64-bit ...


21

Those are called qubits, and are used in quantum computers. You'll find more information about them on the wikipedia entry. Research is being done to make such computers that are stable and economically feasible.


21

You're basically describing an analog signal, which are used in sensors, but rarely for internal computations. The problem is noise degrades the quality, you need very precise calibration of a reference point that is difficult to communicate, and transmission is a problem because it loses strength the farther it travels. If you're interested in exploring ...


19

Physical characteristics of the universe (like the number of atoms in it) are not useful to determine the boundaries of number sizes, because useful calculations exist using numbers having wider ranges. Floating point numbers are a tradeoff between accuracy and range. They deliberately give up some accuracy to achieve greater range.


19

Because switching to integers doesn't solve anything. The problem with floats isn't that they have inaccuracies, it's that half the people using them don't pay any attention to what's going on. Those same people aren't going to pay proper attention to the units they are using when they use an integer, and a different set of screw ups will happen. Repeat ...


17

A matter of accuracy One reason we use bits is that it helps us store and retrieve information accurately. The real world is analog, therefore all the information computers pass or store is ultimately analog. For example, a current of a specific voltage on a wire, or magnetic charge of a specific strength on a disk, or a pit of a specific depth on a laser ...


14

Because most of the processors that you use in your day to day life are not modern day 64 bit processors with crazy fast integer calculations or an over abundance of space. Most of your processors are 8-16 bit devices which run things like your car, microwave, or watch. Besides, what happens when you need to talk about a half of a unit, like a half of a ...


11

The problem is the line byte q1 = keyboard.nextByte() * 10;. There are no arithmetic operations on byte or short. The value of keyboard.nextByte() is casted up to an int prior to multiplication with 10, which is also an int. The result of the multiplication is an int, which can not be stored into q1 if it's defined as a byte. Possible solutions would be to ...


10

In the hopes of giving you a better idea of how this all works together, I'm going to break this down into a few different sections. Feel free to skip sections you feel confident you know enough about. Operating Systems Operating systems are large pieces of software that manage the resources of the computer and allocate them out to other applications ...


10

Is the ID always in the form: IO123456? What your colleague could mean is that he only sends the numeric part, which fits easily in 4 bytes omitting the "IO" part.


10

There are also ternary computers instead of binary ones. http://en.wikipedia.org/wiki/Ternary_computer A ternary computer (also called trinary computer) is a computer that uses ternary logic (three possible values) instead of the more common binary logic (two possible values) in its calculations...


10

Using a float instead of a high precision integer (with conversions!) is simply easier and faster. I can type in float myVar = 0.15; //my value... and move on to the rest of the logic of my simulation. I don't have to spend extra time thinking about converting to int and making sure that all of my scales are correct. And the results end up being good ...


10

I'm working on a report as I type this. One of the fields is a long milliseconds of duration that I got from somewhere else. This is going to be sent to Microsoft Excel and the duration units it uses is decimal days (1.25 = 1 day, 6 hours). Sure, you can subdivide a range from the lowest possible value to the largest and have integer units stepping ...


9

You need log2(n) bits to address n bytes. For example, you can store 256 different values in an 8 bit number, so 8 bits can address 256 bytes. 210 = 1024, so you need 10 bits to address every byte in a kilobyte. Likewise, you need 20 bits to address every byte in a megabyte, and 30 bits to address every byte in a gigabyte. 232 = 4294967296, which is the ...


9

The abbreviations for bits and bytes are differentiated by their case: lower case (b) means bits and upper case (B) means bytes.


9

How do I tell a user that one means bits per second while the other means bytes per second and how would I style the lettering Seems like this is one of those things that you get to decide as the designer of the program. There are lots of options, including but not limited to: spell it out: Eliminate the ambiguity by simply writing "bytes/sec" or ...


9

AFAIK, no answers presented here are correct. The size of bool and _Bool is not constrained to be 1 byte (I seem to remember that there is a constraint in C which forces sizeof(_Bool)<=sizeof(short) which hasn't an equivalent in C++)


6

If the first two characters are not constant (but are always letters) and the remaining six characters are always numbers, a string like "IO123456" can be packed into 5 bytes by converting the numbers into binary-coded decimal (BCD) format: IO123456 -> 0x49 0x4f 0x31 0x32 0x33 0x34 0x35 0x36 | | \ / \ / \ / ...


6

Seven bits for ASCII information, and one for error-detecting parity.


4

It might well be more natural to us but there are specific reasons why binary was chosen for digital circuitry and thereby for programming languages. If you have two states you only need to distinguish between two volt settings say 0V and 5V. For each additional increase to the radix (base) you'd need to further divide that range thus getting values that are ...


4

I'd say the answers are both D) but the questions do leave a bit to be desired, for the first as AProgrammer points out, a bool could be bigger than 1 byte, for the second question it should clarify the smallest unit of addressable memory (bitfields allow a structure of multiple smaller memory units but they aren't addressable) to clarify why C) is not the ...


4

Because sometimes even a 64-bit integer won't give you enough range. For example, in the physics code I'm currently working on, I need to convert some molecular masses between grams per mole (which the input / output format uses) and kilograms per molecule (which the internal calculations need for unit consistency). There are about 279 molecules in a mole, ...


3

Existing answers have explained that the formula for addressing ram is 2^BITS = Addressable ram, but have not explained why. Consider a system with 2 bits. It can address 4 bytes of ram as follows: Byte 0: 00 Byte 1: 01 Byte 2: 10 Byte 3: 11 For each additional bit, we can address twice as much memory. E.g., add a 0 bit to each for bytes 0-3, then add ...


3

You need the log (base 2) of the N bytes in order to address N bytes of RAM directly. 4 GB = 2^32 bytes log_2( 2^m ) = m so log_2( 2^32 ) = 32 So a 32-bit address lets you directly reference 2^32 bytes (4 GB). A 64-bit address lets you directly reference 2^64 bytes (16 exabytes).


3

Take a look at Wikipedia page on 8-bit architecture. Although character sets could have been 5-, 6-, then 7-bit, underlying CPU/memory bus architecture always used powers of 2. Very first Microprocessor (around 1970s) had 4-bit bus, which means one instruction could move 4-bits of data between external memory and the CPU. Then with release of 8080 ...


3

Why do programmers still use floats? To the (generally good) answers which are already here, I would add: Because most programming languages don't provide a "decimal" type, or at least don't make it as convenient to work with as a float. If they are built in to the language and convenient to work with, arbitrary-precision decimal numbers are much more ...


2

I think you could nowadays built items that could hold any amount of states or even work with analog data. Though building a whole system and getting all the logical components running to get a full featured and programmable architecture would be a lot of work and a financial risk for any company to undertake this task. I think ENIAC was the last ...


2

A clue and an inkling are smaller pieces of information than a bit. Several clues are usually required to establish the definite value of a bit. Inklings are worse: no matter how many you add up, you still can't know the value of the resulting bit for certain. More seriously, there are multi-valued logics where the fundamental unit can have one of n states, ...



Only top voted, non community-wiki answers of a minimum length are eligible