Wikipedia:Reference desk/Archives/Computing/2012 August 5

= August 5 =

laptop versus Ipad
Daughter going to college. We just spent over two grand on a new laptop. My work keeps me away from home four weeks at a time. My wife informed me last night our daughter insisted on having an Ipad as she could not do certain things on laptop the Ipad could, take notes in class was only example given. What are the advantages of having an Ipad along w/ a computer while/when going to college? — Preceding unsigned comment added by Twbtr (talk • contribs) 11:15, 5 August 2012 (UTC)
 * Except for being somewhat being more portable and theoretically more "trendy" I would say there are none whatsoever, she could just as easily take notes on a laptop, in fact probably more easily since I imagine she's more experienced using a keyboard than a touch screen-- Jac 16888 Talk 11:25, 5 August 2012 (UTC)


 * I would have agreed with Jac16888 until about five months ago when my wife got an iPad. I'm a hardcore computer nerd; on the face of it, the iPad didn't appear to me to be much other than provide a very pretty machine to look at cats and buy stuff. But my wife is not a computer nerd — she's just someone who wants to use a computer and not worry about it. If you pair the iPad with a bluetooth keyboard (there are some good models out there with real keys), it suddenly becomes an ultra-compact, ultra-easy, ultra-light laptop. No joke. My wife basically doesn't use her laptop anymore at all, because it adds a huge amount of weight and general laptop cruft that she doesn't need — all she wants to be able to do with a computer is write documents, check e-mail, surf the internet. And an iPad (with an external keyboard!) does that just fine. (We find the "on screen keyboard" thing just too unreliable to use for serious work, but maybe younger hands have an easier time with it.)
 * As a second point of data, I will just say that in my experience as an educator, students today are indeed using iPads as a replacement for both notebooks and laptops. It's very common, and they get a lot out of them. Many get stuff out of them that at the moment you can't do with a laptop, like using a stylus that honestly works well (instead of typing).
 * I will also just say that carrying around an iPad is usually a lot lighter than carrying around a laptop, even a very small and thin laptop. Keep in mind that women in general already carry around more stuff than men do because of the purse; my wife was finding that years of carrying around a MacBook AND a purse were taking a toll on her shoulder muscles; switching to the iPad made a noticeable improvement in the reduction of weight. Whatever you get her, be aware that its weight will likely make the difference between whether she actually feels she can take it to class, versus leaving it at home and essentially serving as a desktop.
 * So I'm not weighing in one way or the other here, except to say that on a site like this, you're talking to people who are above average when it comes to our expectations of what computers should do — but that's not necessarily tailored to the work your daughter will need to do in college. I wouldn't be able to substitute an iPad for a laptop, but I'm not your daughter. The students I have seen that are her age, and even my dear wife, actually find iPads to be significantly more useful than that. (And if they do need "real computers," all colleges have computer labs where they can use them, these days.) --Mr.98 (talk) 13:06, 5 August 2012 (UTC)
 * If the weight factor is the only real difference though I would consider spending more money on an Ipad after already spending 2 grand on a laptop for college to be unnecessary. OP you could always look into other tablet computers, you can get ones with much the same functionality for considerably less money-- Jac 16888 Talk 13:42, 5 August 2012 (UTC)
 * My experience is that most of the other tablets on the market don't really compete when it comes to user interface, apps, etc. That will probably change, but if you compare them side by side, the iPads usually kick their butts in every category. They cost a lot, but they're also the result of a lot of careful R&D. Again, it depends on what you're trying to use them for. I wouldn't have much use for one myself. But for something that is much smaller than even a netbook, and works a hell of a lot better than any netbook I've seen (and a better screen than even any laptop I've owned), it does do the trick. --Mr.98 (talk) 18:04, 5 August 2012 (UTC)

You can also for less than $2000 get an incredibly swanky Lenovo Thinkpad convertible tablet, which is essentially both a tablet and laptop in one, as well as being significantly more powerful and useful in every respect than an iPad, and also having a considerably more useful screen which includes not only touch (finger) based input (like an iPad), but also what is called an active digitizer (which is much more precise for taking notes and/or drawing with a stylus, like a wacom tablet). Taking notes in class on an iPad as I understand it tends to require a very large-ended stylus to simulate the size of a finger. I'm sure it would suffice, but technologically speaking it's a step back. Lenovo (and HTC) also have some non-convertible tablets (cheaper) that are more like iPads but still have the superior touchscreens (finger + stylus, not just finger). Any of these alternatives would be a better choice than an iPad, IMO, but not everyone wants an iPad because they think it's the best choice... some just want one. :p ¦ Reisio (talk) 16:48, 5 August 2012 (UTC)
 * Indeed. iPads are more expensive than non-Apple tablets, but you can get them for less than $2000.


 * Have you personally used a tablet/laptop? I've played with them but they've never worked well. They seem to suck both as laptops and tablets both. Anyway, long story short, there are differences between the different models. I know the "boo Apple, you're paying too much for proprietary products just to be cool" line of argumentation, but personally if I were picking a machine for a non-nerd, the iPad is the easiest damned thing they'll ever use, and everything "just works." That's not been by experience with other operating systems and hardware. My wife has had both a Toshiba tablet/laptop and the iPad; the Toshiba one turned out to be a complete piece of junk, the iPad is the one she uses all the time. We're not Apple fanboys or anything like that — it's just easier to use, looks better, etc. --Mr.98 (talk) 18:04, 5 August 2012 (UTC)


 * I agree, a version of Mac OS is going to be less awful in general than a version of Microsoft Windows, but Android is also in the mix, and we can only speculate as to what OS his daughter is used to and what her competency is, and competitors _are_ cheaper (though obviously cost isn't an issue in this case), and the screen I mentioned is immensely more useful for writing/drawing with. The only thing that is perfectly clear is that from a hardware perspective, you can get something cheaper and with a more useful screen for note taking by not buying Apple.  ¦ Reisio (talk) 18:20, 5 August 2012 (UTC)


 * Put simply, an iPad is a primitive, hard-to-set-up computer. Simple things like printing require extra setup work on your part. For example, to print, you can't just install print drivers on the iPad and then hook up a USB cable to a printer. Instead, you first have to install an application on both the iPad and a real computer. The drivers also have to be installed on the real computer. The real computer then prints the document once it receives it from the iPad. Other tasks like transferring files between an iPad and a real computer require that you use Apple's proprietary dock connector and an adapter you purchase separately. Then you have to install the buggy iTunes application on a real computer and use it to transfer the files. Other tablets and phones typically don't have proprietary connectors and can use the file explorer that is built into your operating system. So, you're paying for a ball and chain that will cost you far more money than the purchase price of the device. Some people say these devices are great for people who are new to computers, but is your daughter brand new to computers? If not, don't buy it. And if you're not really good with them, you'd probably have to pay someone to set it up and maintain it for you. Apple decides which applications you can purchase from their app store and which devices can use the store. If they decide that your iPad is too old, they may cut you off from the store. They haven't done that, yet, but it's one of the many things they can do since they control it. It may be smaller than a laptop, but doing things like typing a letter or e-mail on the device will be slower without a physical keyboard. So, then you purchase a Bluetooth keyboard, which diminishes the portability of the device when deployed, and it reverts to the size of a small laptop.&mdash;Best Dog Ever (talk) 20:58, 5 August 2012 (UTC)
 * Just to set the record straight, Best Dog Ever, AirPrint is built in to iPad. AirPrint is a standard technology supported by most printer models, produced every major printer manufacturer I am aware of.  (Over two hundred printer models currently support this technology).  That means that in practice, you will never need to install any driver or buy any cable to print a document from an iPad.  All you need is a WiFi connection, and any one of several dozen compatible brands or models of printer.  Granted, if you're trying to print to a 15-year-old dot-matrix printer, or an IBM 4019, you might need a Unix hacker to set up a CUPS relay... but let's be serious, this is 2012.  A brand new printer costs under fifty dollars, so if you've found yourself spending more than an hour setting up drivers for a defunct, out-dated printer on any platform or computer (iPad or otherwise), you've probably wasted more time than it's worth.
 * I was a little bit offended by the "primitive" description used above; but it is a totally unsubstantiated claim and is very easy to refute. iPads are great for a variety of tasks.  Many users check email, take notes, and use applications from the store.  Other users who are technically proficient write their own software for the iPad.  In addition to its easy user-friendly interface, the iPad is great for programmers.  It is a fully-programmable, Turing-complete system, with an advanced Unix-based operating system.  iOS provides numerous facilities to allow programmers to use the latest and greatest hardware - for example, accessing iPad sensors like the MEMS accelerometers that aren't even present in most Intel-style computers today - or the iPad's state-of-the-art, low-power 3D graphics accelerator hardware.  The developer program is not free to join - but it costs less than my Deitel & Deitel "How to Program" textbook, and the iOS Developer Tools come with a lot more example code, documentation, and up-to-date information.  Were I in school today, I would seriously consider purchasing an iOS developer subscription instead of an introductory programming textbook.  So, whether you're a novice computer user or a kernel hacker, you'll probably be able to do something useful with these machines.
 * On a last note, you do not need to purchase a dock-connector separately. It is included in the box with the iPad.  While I respect your right to your opinion, which is clearly biased against the iPad, I can't see how you justify resorting to factually-incorrect statements to slander the product.  Nimur (talk) 22:40, 5 August 2012 (UTC)
 * I purchased a good Canon printer a couple of years ago and it didn't come with Airprint support. I doubt the laser printers at her school support it, either. And in any case, I don't feel like replacing a good printer with a cheap, $50 model just to work around the iPad's limitations is worthwhile. And again, that workaround proves my point about the iPad being hard to work with.


 * If you do business with Apple, they will exploit you every step of the way to get more money out of you. Is your battery dead? Sorry. You can't replace it. You have to buy a new iPad. You want a new application? You have to buy it directly from us via our App Store, not online from anyone else.


 * I won't get into a debate about the technical underpinnings of the iPad. The fact is that it is primitive because of the end-user features it lacks -- not because of any theoretical limitations in the technology that underpins it.


 * Anyone who wastes lots of money on a product will get offended when you point out they wasted their money. They will also attempt to justify their purchase in a classic case of cognitive dissonance. For example, you will get an identical reaction to yours from BMW owners when their brand-new cars break down. They will start talking about how fast it is, how good it handles, etc., in an attempt to overlook the fact that it's just not a very good car. The same is true with iPad owners.&mdash;Best Dog Ever (talk) 23:28, 5 August 2012 (UTC)
 * The only thing more irritating than frothing pro-Apple fanboys are frothing anti-Apple hater. It's easier if you just admit that you're not the target audience. It's a machine which proudly proclaims that it is built for a certain type of use, and constrains your usage as part of the trade off you get with no viruses, ease, and simplicity. It's not for everyone, but calling such a thing "primitive" is as erroneous as saying that dogs are "lesser evolved" because they can't do calculus. --Mr.98 (talk) 02:42, 7 August 2012 (UTC)


 * Another thing that makes iPads hard to use is their over-reliance on "apps." It's largely due to Apple's refusal to allow Java and Flash on their mobile devices. So, if you want to do simple things like watch online videos, you often have to go to the Apple Store and get an app just for that web site. Some charge money for their apps, so add that to the price tag of the device.&mdash;Best Dog Ever (talk) 23:49, 5 August 2012 (UTC)
 * Somewhat OT but unless you're doing very little printing a $50 printer is usually a bad idea anyway as they tend to have extremely high ink costs. More expensive printers, even inkjet ones tend to be better from a cost standpoint particularly if you shop around and look for useful features like seperate ink catridges. Also AFAIK, you still need a Mac OS X computer to develop for iOS . I've been wondering whether to get involved in either this or the earlier discussion on iPads. I have a resonable amount of experience with an iPad 2 and limited experience with a crappy/cheap Android tablet (as well as experience with an Android phone).
 * I admit to never being an Apple fan and even with my iPad 2 experience this hasn't changed. Yes the iPad is a great device in some areas but using it has also reaffirmed my believe that with Apple devices it's usually a case of their way or the highway. Uploading files was mentioned above but in reality, transferring files to an iPad isn't easy even with the dock connector (which does AFAIK come with the iPad, you couldn't charge otherwise). You either have to use iTunes or some external iPad app or do it over the network (e.g. run a webserver locally or do it over the internet e.g. transfer it via email or upload it to some cloud storage solution). And even after you've transferred files, the iPad doesn't expose or allow access to the filesystem unless it's jailbroken. So if you have a file transfer app and a media player, you have to make sure they're playing together nicely, otherwise you transfer your files only to find out they can't be played even if the media player is capable of it.
 * Speaking of jailbreaking, it's something talked about so much that you may think it's guaranteed. I reality, Apple is serious about not wanting their devices to be jailbroken, more so then many Android devices barring perhaps some Motorola device. For example the iPad 2 I was playing with came with iOS v5 and it was only several months before there was a public method of jailbreaking.
 * The battery issue was mentioned, another case is the screen glass. If it cracks, the only option Apple offers is a refurbished iPad for US$350 or whatever it is. If you want it repaired, you need to go to a third party. (Apple may repair them by sending them back to China.) And from what I've read and seen, it isn't actually that hard to crack, drop it the wrong way and there's a fair chance it will crack. (There's some suggestions at least some Android devices are better in this regard however I haven't seen any good evidence. But definitely unlike the the iPhone and with some tablets from what I can tell precisely what sort of glass is on the iPad has never been confirmed.) You may say be careful, but given the way the device is meant to be used and carried around, I don't think you can say everyone who breaks one was simply too careless. Apple do offer their accidental protection insurance and of course you can rely on your contents or credit card insurance if it exists, but their refusal to offer repair as an option does to me seem to be another case of their way or the highway. (From what I've read in the past you may have been able to get your device replaced for free if it was the first time, particularly if you had lots of Apple devices, at an Apple store if you were lucky. But of course that relies on luck and having an Apple store near you. In any case, from what I've read they've abandoned it after they started offering AppleCare+.)
 * As for the interface, I'm not the sort of user it's targetted for and as I've said I haven't really used a good Android tablet (although I did have a limited amount of experience with 4.0 to see something which I think would have preferred if it was actually working well). But from what I've seen and read, starting from 3.x and particularly with 4.x, Android is moving away particularly on the tablet front from simply trying to copy whatever Apple does to trying to make their own distinctive interface which IMO seems better for an experienced user who wants more from their tablet then simply watching video, simple internet browsing, a few quick emails, chatting and the odd game. (This doesn't mean the Android device is extremely hard to use, it may be slightly harder but it also provides a far greater ability to customise and modify things to your preference. A common criticism of the iPad from those in the Android community is interface wise it's basically just a big iPod Touch.)
 * BTW, writing documents was mentioend above. I have to say from my experience with the iPad, trying to do any serious writing work with the iPad using only the soft keyboard is an excercise in frustration. Perhaps I just didn't use it long enough to get used to it and I also never tried any of the fancy document editing apps, but I don't think so. Typing is one thing, you can get to a decent level although probably still not close to a touch type level. But trying to do basic tasks like copying and pasting or going back to edit something can be very annoying, I'm sure people get much better then me at selecting via the touchscreen but I doubt they ever get close to the level of a decent typist using a physical keyboard with cursors keys. So I'd have to agree with the other suggestions that for serious writing work particularly of the sort I presume would be necessary for university, you'd almost definitely want a physical keyboard (and depend on the user, I'd suggest a mouse or some other mouse like selection device). Don't get me wrong, the touch screen interface is great and far simpler to use for some purposes but this sort of precise and accurate editing work isn't it. Incidentally speaking of the soft keyboard, this is another area of Apple's way or the highway. Unless you've jailbroken the iPad, the ability to customise or replace the keyboard is limited.
 * When it comes to comparing features, it's worth cutting thru the hype and actually looking at the difference. For example the iPad(3) LCD gets a lot of attention. I don't know enough to comment on whether in pure display terms it's really better then every other Android tablet. But IMO the issue of resolution and PPI gets way too much attention. While it may be better then most other Android tablets, I haven't seen any real evidence that level of resolution or PPI actually make a significant difference to the user in itself. Remember that (AFAIK anyway) whatever Apple's marketing department may have claimed, no one in Apple has ever denied that the primary reason why they ended up with 2048 x 1536 instead of the 1920x1200 or 1920x1080 which some Android tablets use is primary one of legacy. Apple choose the 4:3 resolution of 1024x768 for the original iPad and it was simpler by far to just double it for their retina display. In other words, it's not that the Apple 2048 x 1536 4:3 resolution is some super improvement in quality terms, it was chosen for technical reasons  (these may be somewhat biased but I don't see any evidence the basic claim is incorrect). Of course the lack of fragmentation, general use of bitmaps and limited scaling in the iPad means that many apps will look good on the iPad3 whereas as I understand it things can be far more hit and miss with Android tablets.
 * One thing I will say is Apple does have a clear cut advantage in the app market in most areas, particularly when it comes to games. (I'm not just talking about numbers, there are plenty of games I've heard of or tried for the iPad which weren't n Android. It's also not uncommon to come across an indie developer, e.g. on kickstarter mentioning the iPad but not Android.) This is somewhat noticable with phones but it's particularly noticable with tablets where many developers still aren't bothering with Android. The issue of fragmentation also directly concerns the user here because even if the app is released, there's a chance the developers may decide not to support you device meaning you won't be able to get it via the Play store without some degree of hacking or convincing the developers your device will work. There are of course a few areas were Android has the advantage. Anything which Apple doesn't allow. Also in the free software community I would say from what I've seen Android tends to win out both because the questionable legality of releasing code under the xGPL on the iOS store (meaning unless it's your own code you'd want to be careful) and also because of Apple's control. (Although the size of the community and even the jailbroken community does mean that the iPad doesn't always have as much advantage as you may expect.)
 * BTW, while I'm not a developer from what I've seen and read, if you're interesting in hacking and generally fooling around, the Android is the far better option, again primarily because of Apple's control and limitations even after you've paid the $99 fee. If you're seriously interested in developing apps, the iPad may be the better reason for the same reason that so many other developers chose it (market share etc) unless you've interested in developing an app which isn't an option there. However given how fast things can change, I would suggest it's a bad idea to completely ignore Android even if you decide it's not worth your efforts at this time.
 * In simplication, IMO the iPad is great for some tasks but while it's likely more polished and will have less problems given the limitations and cost. Either go with a cheaper Android tablet if you primarily want it for stuff like gaming (even bearing in mind the limitations), video, browsing, email and chat (unless you're very rich); or go with a better one if you want to do more complex stuff (again unless you're very rich and can afford both). I may come across as a bit of an Android fanboy but if anything I'm more of a Microsoft one. I do think it'll be interesting to see whether the Microsoft Surface (or some other Windows 8 device) can really pull it off since as I've said from where I stand, the tablet is great for some uses but there are other uses where a physical keyboard and other features which I haven't mentioned but you expect from a traditional laptop like real multitasking.
 * P.S. Sorry I missed someone already mentioned the requirement for the iTunes until now.
 * P.P.S. While I do somewhat agree about the overeliance on apps comment, I don't think it applies to watching videos online. If you want to watch videos you've either converted yourself or downloaded from source (dodgy or not) you may need a media player. If you want to watch videos many sites are moving to providing HTML5 as an option but if not and they're still using Flash, you're usually screwed. On some occasions an app may be available for the site which provides videos when they don't provide HTML5, but from my experience this is rare.
 * Nil Einne (talk) 19:05, 6 August 2012 (UTC)

How many bits?
How many bit does the number 0, 4 or 23 or whatever occupy in binary, hexadecimal or decimal? OsmanRF34 (talk) 18:53, 5 August 2012 (UTC)
 * Bits are always binary -- the word "bit" stands for "binary digit". The number of bits that a number occupies depends on how it is encoded.  You might benefit from reading our bit article. Looie496 (talk) 20:29, 5 August 2012 (UTC)


 * (Edit Conflict)
 * For it to occupy bits, it must be either be stored directly as a binary number (the "b" of bits stands for binary), or encoded into some form which is then encoded into binary...
 * If you store it directly as a binary number, then the the minimum number of binary digits (bits) needed to store a number n is log 2(n) (rounded up to the next non-zero positive integer). Most calculators won't allow you to calculate logarithms with arbitrary bases, but thanks to this property of logarithms you can use log(n)/log(2) - the answers for the three examples you gave are 1 bit, 2 bits and 5 bits respectively - .  This is a bit of a simplification - in particular:
 * 1 - the number of bits isn't actually a function of the number you're storing, but the longest number you may wish to store
 * 2 - I've glossed over the question "how many digits does it take to store zero" (in a way, this is a special case of point #1)
 * To store a number as BCD takes 4 bits per decimal digit
 * To store the number as text will typically take 8 bits per digit, plus 8 bits as a termination character
 * Hope this helps, cheers, d avid p rior  t/c 20:38, 5 August 2012 (UTC)


 * Perhaps you meant to ask the minimal number of digits needed:


 * "0" is the same in all systems, so just 1 digit is needed (but leading zeroes can change that, like "0000").


 * "4" is 1 digit in either decimal or hex (where it's also "4"), and is "100" in binary, or 3 digits minimum.


 * "23" is 2 digits in decimal or hex (where it would be "17"). It would be a minimum of 5 digits in binary ("10111"). StuRat (talk) 20:41, 5 August 2012 (UTC)
 * Yep, I made an out-by-one error :-)  Thanks StuRat for spotting it,  d avid p rior  t/c 10:39, 6 August 2012 (UTC)
 * So the corrected formula would be 1 + int(log(n)/log(2)) - where int is a function which always rounds down.   d avid p rior  t/c 13:02, 6 August 2012 (UTC)
 * Just as an oddity - the minimum number of bits required to store a number is one less than you quote. Since the top bit is always 1, it can be inferred - 4 would be 00 and 23 0111.  Not sure the cost of disk space makes this worthwhile, though :-) --Phil Holmes (talk) 09:35, 6 August 2012 (UTC)
 * That would leave you unable to represent 0. Also you would need some way to represent how long your number was.  It's correct that 4 could be 00 and 23 could be 0111, but what do you do when you need to store both? If you always have 4 bits then you can't infer the leading 1 because then 0111 would be 23, and not 7. Floating point numbers is a different matter because you store additional information Taemyr (talk) 12:46, 6 August 2012 (UTC)
 * You have variable length numbers, just like we do in decimal.--Phil Holmes (talk) 12:55, 6 August 2012 (UTC)
 * Yeah, but if you have variable length numbers, you some way to identify where one number ends - which will itself add to the overall length.  d avid p rior  t/c 12:59, 6 August 2012 (UTC)


 * Technically, you don't need any bits to represent a zero. You can have an object that takes up no storage space and know that whenever you reference it, you have a zero.  You only need storage if you need to distinguish one value from another (say 0 from 1).  As for the general question, it depends on representation, range, and precision.  The most common numeric binary representations may not be the only choices depending on range and precision needs.  Offset binary representations encodes a range of values using fewer bits than would be needed when using a common unsigned or signed binary integer representations.  Fixed-point_arithmetic can define the least significant bit as having a value other than one.  Often this may be a fraction, such as 1/32,768 for a real-time clock or 1/10,000 for some binary representations of currency values, but the the implied radix point could also be offset in the opposite direction where the least significant bit represents a value greater than one.
 * For example, the MSDOS FAT12 file systems (and successors) packed a file's last modification date and time into two 16 bit values which were further subdivided into bit fields (see ). To save space, the year was represented using an 1980 base, where 7-bit binary values 0000000 to 1111111 represented the years 1980 through 2107.  The seconds values used 5-bit binary values 00000 to 11101 to represent the range 0-58 in two-second increments.  (This is still be apparent in FAT32 systems such as thumb drives, where the modification time will always be stored as a multiple of two seconds.)
 * An even more general question could be asked regarding a discrete set of N distinct values, such as a {1, 2, 5, 10, 20, 50, 100, 200, 500, 1000}. In this case, each value could be mapped to a bit pattern unrelated to its binary representation.
 * Bottom line: The answer depends on the representation, range, and precision that ultimately defines the set of values to be considered. The general question could be restated in any of the following manners, yielding different answers for the same value:
 * Q: How many bits does it take to represent X as an unsigned binary integer?
 * A: $$\lfloor \log_2 (N) \rfloor + 1$$ bits when positive. Zero bits when zero.  (where "$$\lfloor ... \rfloor $$" represents the Floor function)
 * Q: How many bits does it take to represent X as an signed two's complement binary integer?
 * A: $$\lfloor \log_2 (N) \rfloor + 2$$ bits when N is positive. $$\lfloor \log_2 (-N-1) \rfloor + 2$$ bits when N is negative.  Zero bits when zero. (This is consistent with normal rules of sign extension.)
 * Q: How many bits does it take to represent all integer values in the range X to Y?
 * A: $$\lfloor \log_2 (Y-X) \rfloor + 1 $$ bits using an offset representation. (Zero bits when X = Y.)
 * Q: How many bits does it take to represent all values in the range X to Y with a resolution of P?
 * A: $$\lfloor \log_2 ((Y-X)/P) \rfloor + 1 $$ bits using an offset and scaled representation. (Zero bits when X = Y.)
 * Q: How many bits does it take to represent any value from a set of N distinct values?
 * A: $$\lfloor \log_2 (N - 1) \rfloor + 1 $$ bits using discrete assigned representations. (Zero bits when N = 0.)
 * The value 23 would require 5 bits to represent as an unsigned binary number (10111), 6 bits as a signed binary number (010111), 3 bits for a set that only needs to represent the values 20.0—23.5 in 0.5 increments (possibly 110), or 4 bits in a set of prime numbers less than 50 (possibly 1001). And I haven't event touched on floating point or variable-length codes.  My apologies for being long-winded — I got on a roll.  --  Tom N (tcncv) talk/contrib 01:43, 7 August 2012 (UTC)