bit

Set the i-th bit to zero? [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: How do you set, clear, and toggle a single bit? 26 answers I would like to set the i-th bit to zero no matter what the i-th bit is. unsigned char pt = 0b01100001; pt[0] = 0; // its not how we do this... Setting it to one, we can use a mask pt | (1 << i) but i'm not sure how to create a mask for setting 0, if thats possible. 回答1: You just have to replace the logical OR with a logical AND operation. You would use the & operator for that: pt = pt & ~(1 << i); You have to invert your mask because logical

I get &#039;A 32 bit processes cannot access modules of a 64 bit process.&#039; exception invoking Process.Start()

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here is the code sample var startInfo = new ProcessStartInfo { Arguments = commandStr, FileName = @"C:\Windows\SysWOW64\logman.exe", }; using (var createCounterProc = new Process { StartInfo = startInfo }) { createCounterProc.Start(); createCounterProc.WaitForExit(); } After running the code I get "A 32 bit processes cannot access modules of a 64 bit process." message in MainModule (NativeErrorCode:299). My solution is configured to AnyCPU. I've tried both 64 and 32 bit versions of logman.exe (C:\Windows\SysWOW64\logman.exe and C:\Windows

long double (GCC specific) and __float128

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm looking for detailed information on long double and __float128 in GCC/x86 (more out of curiosity than because of an actual problem). Few people will probably ever need these (I've just, for the first time ever, truly needed a double ), but I guess it is still worthwile (and interesting) to know what you have in your toolbox and what it's about. In that light, please excuse my somewhat open questions: Could someone explain the implementation rationale and intended usage of these types, also in comparison of each other? For example, are

gcc ld: symbol(s) not found for architecture x86_64

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Alright so I'm making a lexer and a parser using Ocamlyacc. I've done my research and I think it's something to do with my makefile not picking the right bit version for my compiler or something like it? I don't know much about makefiles which is why I'm asking. I've run my program on another computer where it works without trouble so it gotta be something to do with my machine. It's a MacBook Pro 64 bit. I'm using Xcode 4.2.1. Here's the makefile: SHELL = /bin/sh C_C = gcc CPP_C = g++ ifdef GPROF C_CPP_FLAGS = -pg -O3 else ifndef DEBUG C

How can I combine 4 bytes into a 32 bit unsigned integer?

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to convert 4 bytes into a 32 bit unsigned integer. I thought maybe something like: UInt32 combined = (UInt32)((map[i] << 32) | (map[i+1] << 24) | (map[i+2] << 16) | (map[i+3] << 8)); But this doesn't seem to be working. What am I missing? 回答1: Your shifts are all off by 8. Shift by 24, 16, 8, and 0. 回答2: Use the BitConverter class. Specifically, this overload. 回答3: BitConverter.ToInt32() You can always do something like this: public static unsafe int ToInt32(byte[] value, int startIndex) { fixed (byte* numRef = &(value[startIndex]

Reverse bit pattern in C

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am converting a number to binary and have to use putchar to output each number. The problem is that I am getting the order in reverse. Is there anyway to reverse a numbers bit pattern before doing my own suff to it? As in int n has a specific bit pattern - how can I reverse this bit pattern? 回答1: There are many ways to do this, some very fast. I had to look it up. Reverse bits in a byte b = ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; Reverse an N-bit quantity in parallel in 5 * lg(N) operations: unsigned

128-bit division intrinsic in Visual C++

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm wondering if there really is no 128-bit division intrinsic function in Visual C++? There is a 64x64=128 bit multiplication intrinsic function called _umul128(), which nicely matches the MUL x64 assembler instruction. Naturally, I assumed there would be a 128/64=64 bit division intrinsic as well (modelling the DIV instruction), but to my amazement neither Visual C++ nor Intel C++ seem to have it, at least it's not listed in intrin.h. Can someone confirm that? I tried grep'ing for the function names in the compiler execuable files, but

How to convert Linux 32-bit gcc inline assembly to 64-bit code? [closed]

匿名 (未验证) 提交于 2019-12-03 02:18:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm attempting to convert RR0D Rasta Ring 0 Debugger from 32-bit mode to 64-bit mode (long mode) in Linux, using gcc. I'm familiar with x86 32-bit assembly (in MS-DOS environment) but I'm a beginner in x86 64-bit assembly and in Linux assembly programming in general. This project is for production use (I need a working non-source debugger), but I also attempt to learn how to do the 32-bit to 64-bit conversion. If possible, I attempt to find a universal way to do 32-bit to 64-bit conversion that could be done on any 32-bit program using

Large (0,1) matrix multiplication using bitwise AND and popcount instead of actual int or float multiplies?

匿名 (未验证) 提交于 2019-12-03 02:15:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: For multiplying large binary matrices (10Kx20K), what I usually to do is to convert the matrices to float ones and perform float matrix multiplication as integer matrix multiplication is pretty slow ( have a look at here ). This time though, I'd need to perform over hundred thousands of these multiplications and even a millisecond performance improvement on average matters to me . I want an int or float matrix as a result, because the product may have elements that aren't 0 or 1. The input matrix elements are all 0 or 1, so they can be

Shifting the sign bit in .NET

匿名 (未验证) 提交于 2019-12-03 02:15:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm reading bits from a monochrome bitmap. I'm storing every 16 bits in a short in the reverse order. If the bit in the bitmap is black, store a 1. If white, store a 0. E.g.: for bitmap: bbbw bbbw bbbw wwww my short is: 0000 0111 0111 0111 The 1st way I tried to do this was: short m; // ... Color c = bmp.GetPixel(j, i); if (c.R == Color.Black) m |= short.MinValue; m >>= 1; // ... After one assignment and shift, I got the expected -32768 (1000 0000 0000 0000). After the 2nd time I got -16384 (1100 0000 0000 0000). I changed my code to use