53
10
It's not too important anymore, but occasionally somebody needs to know.
Here is a simple golf: Taking no user input, tell me if the computer on which the code is run is on a 64-bit operating system, or a 32-bit operating system!
If the code is run on a 32-bit operating system, print "32", if the code is run on a 64 bit operating system, output "64". Important: Print any other non-empty string of alphanumeric characters if it's neither 32 or 64 bit.
Please note that a 32 bit program running on a computer with a 64 bit operating system should output "64". You can assume that users will use 64 bit software whenever possible.
To be eligible for entry, your code must be able to run on Windows 4.10 or newer Microsoft supported Windows systems, and at least one flavor of Linux of your choosing (so long as that flavor is gratis). Compatibility mods can be installed, so long as the program still returns the right value.
The usual code-golf rules apply.
Note: If your answer is only meant to print out 32 or 64, but not the alt case, I'll accept it, but it is not a competing answer.
I'll try and post some results of running these codes on different OSes later!
What does "You can assume that users will use 64 bit software whenever possible" mean? What software are you referring to? – NobodyNada - Reinstate Monica – 2017-06-20T02:44:18.823
5So "Please note that a 32 bit program running on a computer with a 64 bit operating system should output "64". You can assume that users will use 64 bit software whenever possible." means that if the interprettor/compiler etc is is available in both 32 bit and 64 bit, then a 32 bit OS, will always run the 32 bit version of the interpreter/etc, and the 64 bit OS will always run the 64 bit interpreter/etc. So worrying about the difference between the program being 32 or 64, and the OS being 32 or 64, is basically only a problem for languages with only 32 bit implementations. Right? – Lyndon White – 2017-06-20T04:33:58.413
"must be able to run on Windows 4.10 or newer" - logical OR (4.10 OR newer)? – TessellatingHeckler – 2017-06-20T06:12:22.823
2Many solutions here would print "32" on a 64-bit OS if a 32-bit compiler was used to compile program. Is this OK? – Martin Rosenau – 2017-06-20T08:54:01.160
15What in the world is "Windows 4.10"? Does that mean Windows 98? Or does it mean Windows NT 4? What do you consider to be "newer" than that? This seems an exceptionally poorly thought-out challenge. – Cody Gray – 2017-06-20T09:47:30.670
Is there anything neither 32-bit nor 64-bit? Are you talking about ARM? – Matthew Roh – 2017-06-20T10:47:39.590
What about a 32-bit operating system running on a 64-bit CPU? – OrangeDog – 2017-06-20T11:07:24.420
1
@SIGSEGV there are loads of 8-bit embedded systems, and some old systems you might get a qualifying OS to run on.
– OrangeDog – 2017-06-20T11:10:45.2871Please note that your code running on non-binary systems still has to print a non-empty string. – Jonny Best – 2017-06-20T20:35:45.150
@JonnyBest we need a "Try it online" for nonbinary decimal computer (MIX?)
– ceilingcat – 2017-06-20T22:29:58.40013
There is no "official windows spec", and nobody refers to Windows 98 as being "Windows 4.10". You are literally the first. So maybe instead of trying to sound cool or official by using version numbers, you should just use the actual product name. By the way, Windows 9x was never available in a 64-bit build, so is it actually legitimate for me to submit an entry that runs only on Windows 98 and just returns "32"? Seems very unfair/unsporting/uninteresting, but would technically be allowed by your rules.
– Cody Gray – 2017-06-21T02:25:40.4201
@CodyGray Re: an answer that only runs on Windows 98
– Mego – 2017-06-21T02:53:05.293Doesn't seem to apply, @Mego. That says "a language's features". Windows 98 isn't a language, it is a target platform condoned by the official rules of the challenge (which, because stated explicitly, seem like they would override any "loopholes forbidden by default" anyway). – Cody Gray – 2017-06-21T02:57:57.900
1@CodyGray That would still clearly be in violation of the spirit of the loophole. Besides, a program that only runs on Windows 98 wouldn't be valid:
To be eligible for entry, your code must be able to run on Windows 4.10 or newer, and at least one flavor of Linux of your choosing (so long as that flavor is free).
– Mego – 2017-06-21T02:59:07.3971You mean I can't write a challenge that has explicit provisions that override the default loopholes, @Mego? That isn't what "default" means. And yes, I'd have to also find a Linux distribution that was 32-bit only and free. Or, I'd pick a free Linux distro that is 64-bit only (and there are a bunch of 'em), then the challenge is just detecting whether Linux or Windows. That goes beyond the point my original comment was trying to make, which is: why specify a family of 32-bit only operating systems as an acceptable minimum target, when the challenge is to detect bitness? Seems nonsensical. – Cody Gray – 2017-06-21T03:07:19.670
3You still haven't answered the question about the Windows version. Does must be able to run on Windows 4.10 or newer mean on Windows 4.10 and all newer versions or on any single Windows version, 4.10 or newer? – Dennis – 2017-06-21T03:08:43.573
@CodyGray The "Windows 98 Resource Kit" published by Microsoft Press in 1998 refers to windows 98 as 2 different releases, depending on the year. 4.10.1998 and 4.10.2222. I omitted the last part as I didn't think it would matter. – tuskiomi – 2017-06-21T03:12:25.457
1I'm not sure why you have an OS restriction at all, but requiring answers to work on Windows 98 would probably invalidate most of the answers. – Dennis – 2017-06-21T03:21:27.260
There's really no point in including Windows 98 in the mix. It didn't have a 64-bit version anyway and, more importantly, nobody has it anymore and testing whether an answer is valid or not becomes that much harder. The verifiability issue persists, to a lesser degree, for Windows XP (16 years old) and Vista (nobody liked it in the first place). – Dennis – 2017-06-21T03:27:40.407
@LyndonWhite correct. – tuskiomi – 2017-06-25T00:58:27.807
1@tuskiomi maybe you could add something more explict, like in my comment to the question then. You can see in lots of comments that there is lots of confusion about this. – Lyndon White – 2017-06-25T01:24:06.753
@SIGSEGV the PowerMac G4 had a 128bit processor. – Skyler – 2017-06-26T23:52:42.187
As soon as you add the "print something" requirement, you essentially rule out OS-independence apart from scripting languages, but then it seems that most of the answers don't handle the "neither 32- nor 64-bit" case because the corresponding language doesn't exist on those platforms anyway. – peter ferrie – 2017-11-11T23:48:49.977