platform-specific

Right shift and signed integer

℡╲_俬逩灬. 提交于 2019-11-27 22:49:44
On my compiler, the following pseudo code (values replaced with binary): sint32 word = (10000000 00000000 00000000 00000000); word >>= 16; produces a word with a bitfield that looks like this: (11111111 11111111 10000000 00000000) My question is, can I rely on this behaviour for all platforms and C++ compilers? Andrew Clark From the following link: INT34-C. Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand Noncompliant Code Example (Right Shift) The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1

How do I check if I'm running on Windows in Python? [duplicate]

霸气de小男生 提交于 2019-11-27 09:35:47
问题 This question already has answers here : What OS am I running on? (24 answers) Closed 5 years ago . I found the platform module but it says it returns 'Windows' and it's returning 'Microsoft' on my machine. I notice in another thread here on stackoverflow it returns 'Vista' sometimes. So, the question is, how do implemement? if isWindows(): ... In a forward compatible way? If I have to check for things like 'Vista' then it will break when the next version of windows comes out. Note: The

Right shift and signed integer

余生长醉 提交于 2019-11-27 04:37:28
问题 On my compiler, the following pseudo code (values replaced with binary): sint32 word = (10000000 00000000 00000000 00000000); word >>= 16; produces a word with a bitfield that looks like this: (11111111 11111111 10000000 00000000) My question is, can I rely on this behaviour for all platforms and C++ compilers? 回答1: From the following link: INT34-C. Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand Noncompliant

How can I find the current OS in Python? [duplicate]

和自甴很熟 提交于 2019-11-26 06:13:26
问题 Possible Duplicate: Python: What OS am I running on? As the title says, how can I find the current operating system in python? 回答1: I usually use sys.platform (docs) to get the platform. sys.platform will distinguish between linux, other unixes, and OS X, while os.name is " posix " for all of them. For much more detailed information, use the platform module. This has cross-platform functions that will give you information on the machine architecture, OS and OS version, version of Python, etc.

What OS am I running on?

这一生的挚爱 提交于 2019-11-25 23:15:36
问题 What do I need to look at to see whether I\'m on Windows or Unix, etc? 回答1: >>> import os >>> print os.name posix >>> import platform >>> platform.system() 'Linux' >>> platform.release() '2.6.22-15-generic' The output of platform.system() is as follows: Linux: Linux Mac: Darwin Windows: Windows See: platform — Access to underlying platform’s identifying data 回答2: Dang -- lbrandy beat me to the punch, but that doesn't mean I can't provide you with the system results for Vista! >>> import os >>