bit

Why does std::fstream set the EOF bit the way it does?

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I recently ran into a problem caused by using fstream::eof(). I read the following line from here : The function eof() returns true if the end of the associated input file has been reached, false otherwise. and (mistakenly) assumed this meant that if I used fstream::read() and read past the end of the file, the function eof() would tell me. So I did something like this (very generalized): for(int i = 0; i The problem came because of what is explained later on the page linked above (which I failed to read initially, thanks to the misleading

n is negative, positive or zero? return 1, 2, or 4

此生再无相见时 提交于 2019-12-03 10:23:13
I'm building a PowerPC interpreter, and it works quite well. In the Power architecture the condition register CR0 (EFLAGS on x86) is updated on almost any instruction. It is set like this. The value of CR0 is 1, if the last result was negative, 2 if the last result was positive, 4 otherwise. My first naive method to interpret this is: if (n < 0) cr0 = 1 else if (n > 0) cr0 = 2; else cr0 = 4; However I understand that all those branches won't be optimal, being run millions of times per second. I've seen some bit hacking on SO, but none seemed adeguate. For example I found many examples to

可持久化数据结构板子整理(可持久化 线段树/字典树/可并堆)

删除回忆录丶 提交于 2019-12-03 10:16:22
静态序列查区间第k大 int update(int x,int l,int r,int k){ int rt=++cnt; sum[rt]=sum[x]+1; L[rt]=L[x]; R[rt]=R[x]; if(l<r){ if(k<=mid){ L[rt]=update(L[rt],l,mid,k); }else{ R[rt]=update(R[rt],mid+1,r,k); } } return rt; } int query(int xl,int xr,int l,int r,int k){ if(l==r)return l; int x=sum[L[xr]]-sum[L[xl]]; if(x>=k){ return query(L[xl],L[xr],l,mid,k); }else{ return query(R[xl],R[xr],mid+1,r,k-x); } } 可持久化字典树 struct trie{ int ch[2],siz,id; }t[50000010]; void insert(int &now,int pre,int bit,long long val){ now=++cnt; t[now]=t[pre]; t[now].siz++; if(bit==-1){ return; } int i=(val>>bit)&1; insert(t[now].ch

Generate 16 bit unique IDs in Android for startActivityForResult()

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I was planning to use generated resource IDs for all my startActivityForResult() codes, so that I can use onActivityResult() in base classes and not have to worry if the derived class used the same code. Unfortunately it seems that the codes are restricted to 16 bits, and resource IDs are 32 bits. Is there a way to generate unique 16 bit IDs instead? 回答1: Actually there is. Moreover you can use standard id as Android resource. Simply just mask your id with 0x0000FFFF and use it wherever you want as ID for startActivityForResult()

Bit shifting left

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Let's say I want to bit shift i twice to the left and store the value in f . f = i << 2 ; Is that correct? How exactly do I do this in C/C++? 回答1: Yes. f = i << 2 Shifts are useful in a number of bit twiddling operations. This used to be a great way to multiply a number by four. However, these days, optimizing compilers tend to take care of that for you. Keep in mind that the two leftmost bits are discarded. 回答2: As an additional note: Even though your question is tagged C++ , it is probably worth noting that C and C++ took

Inno Setup install to SysWOW64 in 32Bit mode

匿名 (未验证) 提交于 2019-12-03 09:52:54
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating an installer which only needs to install 32bit files, they work on both 64 and 32 bit machines. I'm running the Inno Setup on a 64bit machine and even though the install mode is 32bit the files still end up in the SysWOW64 folder. The Dest directive sets to {sys} Source: "C:\Users\Lablabla\Documents\Visual Studio 2013\Projects\Test\MyDll.dll"; DestDir: "{sys}"; Flags: 32bit The weirder thing is that the log shows that the destination is system32 and installation mode as 32-bit 2015-04-12 01:04:14.046 64-bit Windows: Yes 2015-04

Bit extension occuring when trying to store a “byte” of information into a %x

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So I currently need to read in a string of hex ASCII characters and use them to determine a specific opcode. To do so I open a text file(its not really but for simple explanation we'll call it that) then read in the line. So if I get a line like 40f1... I have the function read the 2 characters and store them as an unsigned int into mem_byte. Then I cast it into a char to use as an array and retain the "byte" worth of information or the numerical value of two hex digits which were obtained by reading in ASCII character representation of 2

Could not load file or assembly CrystalDecisions.ReportAppServer.ClientDoc

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've looked at similar questions on SO, but nothing quite matches my issue as far as I can tell. The exception message: Could not load file or assembly 'CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified. The file is in my GAC. I am developing on a 32 bit machine (Windows 7) running VS2010, everything is .NET4. The target hosting machine is 64-bit Win 2008 R2. My local machine has the CR installation for

A Generic error occurred in GDI+ in Bitmap.Save method

匿名 (未验证) 提交于 2019-12-03 09:05:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on to upload and save a thumbnail copy of that image in a thumbnail folder. I am using following link: http://weblogs.asp.net/markmcdonnell/archive/2008/03/09/resize-image-before-uploading-to-server.aspx but newBMP.Save(directory + "tn_" + filename); is causing exception "A generic error occurred in GDI+." I have tried to give permission on folder, also tried to use a new separate bmp object when saving. Edit: protected void ResizeAndSave(PropBannerImage objPropBannerImage) { // Create a bitmap of the content of the fileUpload

ImportError DLL load failed importing _tkinter

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using python 2.7.2 and windows 7. I searched through internet, helps and other sources but i can't find an answer to my problem. One of my source imports tkinter , and this one imports _tkinter . At this moment it say ImportError DLL load failed : Traceback (most recent call last): File "NERO/show_image.py", line 13, in import Tkinter File "C:\Python27\lib\lib-tk\Tkinter.py", line 38, in import FixTk File "C:\Python27\lib\lib-tk\FixTk.py", line 65, in import _tkinter ImportError: DLL load failed: %1 is not a valid Win32 application. 2012