Search Results

Search found 180 results on 8 pages for 'xor'.

Page 5/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Basic question about encryption - what exactly are keys?

    - by Tomas
    Hi, I was browsing and found good articles about encryption. However, none of them described why the key lenght is important and what exactly the key is used for. My guess is that could work this way: 0101001101010101010 Key: 01010010101010010101 //the longer the key, the longer unique sequence XOR or smth: //result Is this at least a bit how it works or I am missing something? Thanks

    Read the article

  • Binary string search on one field.

    - by CrazyJoe
    I have 300 boolean fields in one table, and im trying to do somithing like that: One string field: 10000010000100100100100100010001 Ha a simple way to do a simple search os this field like: select * from table where field xor "10000010000100100100000000010001" Im tring this but is to long: select * from teste where mid(info,2,1) and mid(info,3,1) :) Help!!

    Read the article

  • Python bitoperators

    - by Neelima
    What do the bit operators like AND(&),OR(|),XOR(^) in python do behind the screen? What do they calculate? I cannot understand the results they give when used in a program? 30&45 yields 12. How can we relate these three? 30|45 yields 63. How are these three related? Please answer this...

    Read the article

  • Make FalseClass behave like TrueClass with meta programming

    - by Edvinas Bartkus
    This is theoretical question: is it possible to change FalseClass behavior to act like TrueClass? It is possible to override to_s, xor, &, | behavior but that is not enough. If you like Test Driven Development, follow my colleague's suggestion: puts "false is new true!" if false puts "never happens" if true Asserts won't work, would it? Is it possible to pass the test successfully?

    Read the article

  • What is the best nuclear missile crypto system?

    - by The Rook
    You are on a submarine and there is an encrypted message that you want to read. Two people must use their keys at the same time in order to obtain the plain text. What is best cryptographic primitive to use? Are the following two implementations suitable? plain_text=decrypt(Key1 XOR key2,ciper_text,IV) plain_text=decrypt(Key1,rc4_encrypt(key2,ciper_text,IV2),IV1)

    Read the article

  • "bin/sh: can't access tty; job control turned off” error when running shellcode"

    - by Nosrettap
    I'm writing shellcode to exploit a buffer overflow vulnerability on a server. To do so I have port binding shellcode that I send to the server and then I run (from a linux terminal) the command telnet serverAdress 4444 where 4444 is the port which I have opened up. The hope is that I will receive a shell back that I can use to execute commands. However, I always end up with the command bin/sh: can't access tty; job control turned off I can't change any of the server code, and I believe the shellcode is correct because I got it from this website (http://www.tsirogiannis.com/exploits-vulnerabilities-videos-papers-shellcode/linuxx86-port-binding-shellcode-xor-encoded-152-bytes/). From my research, it appears that this may have to do with the mode that my terminal is running in (something called interactive mode...or something like that). All computers involved are linux machines and the machine that I am on is running the latest version of Ubuntu. Any ideas what this job control error means and how I can fix it?

    Read the article

  • C/C++: Who uses the logical operator macros from iso646.h and why?

    - by Jaime Soto
    There has been some debate at work about using the merits of using the alternative spellings for C/C++ logical operators in iso646.h: and && and_eq &= bitand & bitor | compl ~ not ! not_eq != or || or_eq |= xor ^ xor_eq ^= According to Wikipedia, these macros facilitate typing logical operators in international (non-US English?) and non-QWERTY keyboards. All of our development team is in the same office in Orlando, FL, USA and from what I have seen we all use the US English QWERTY keyboard layout; even Dvorak provides all the necessary characters. Supporters of using the iso646.h macros claim we should them because they are part of the C and C++ standards. I think this argument is moot since digraphs and trigraphs are also part of these standards and they are not even supported by default in many compilers. My rationale for opposing these macros in our team is that we do not need them since: Everybody on our team uses the US English QWERTY keyboard layout; C and C++ programming books from the US barely mention iso646.h, if at all; and new developers may not be familiar with iso646.h (this is expected if they are from the US). /rant Finally, to my set of questions: Does anyone in this site use the iso646.h logical operator macros? Why? What is your opinion about using the iso646.h logical operator macros in code written and maintained on US English QWERTY keyboards? Is my digraph and trigraph analogy a valid argument against using iso646.h with US English QWERTY keyboard layouts? EDIT: I missed two similar questions in StackOverflow: Is anybody using the named boolean operators? Which C++ logical operators do you use: and, or, not and the ilk or C style operators? why?

    Read the article

  • Help in building an 16 bit os

    - by Barshan Das
    I am trying to build an old 16 bit dos like os. My bootloader code: ; This is not my code. May be of Fritzos. I forgot the source. ORG 7c00h jmp Start drive db 0 msg db " Loader Initialization",0 msg2 db "ACos Loaded",0 print: lodsb cmp al, 0 je end mov ah, 0Eh int 10h jmp print end: ret Start: mov [ drive ], dl ; Get the floppy OS booted from ; Update the segment registers xor ax, ax ; XOR ax mov ds, ax ; Mov AX into DS mov si,msg call print ; Load Kernel. ResetFloppy: mov ax, 0x00 ; Select Floppy Reset BIOS Function mov dl, [ drive ] ; Select the floppy ADos booted from int 13h ; Reset the floppy drive jc ResetFloppy ; If there was a error, try again. ReadFloppy: mov bx, 0x9000 ; Load kernel at 9000h. mov ah, 0x02 ; Load disk data to ES:BX mov al, 17 ; Load two floppy head full's worth of data. mov ch, 0 ; First Cylinder mov cl, 2 ; Start at the 2nd Sector to load the Kernel mov dh, 0 ; Use first floppy head mov dl, [ drive ] ; Load from the drive kernel booted from. int 13h ; Read the floppy disk. jc ReadFloppy ; Error, try again. ; Clear text mode screen mov ax, 3 int 10h ;print starting message mov si,msg2 call print mov ax, 0x0 mov ss, ax mov sp, 0xFFFF jmp 9000h ; This part makes sure the bootsector is 512 bytes. times 510-($-$$) db 0 ;bootable sector signature dw 0xAA55 My example kernel code: asm(".code16\n"); void putchar(char); int main() { putchar('A'); return 0; } void putchar(char val) { asm("movb %0, %%al\n" "movb $0x0E, %%ah\n" "int $0x10\n" : :"r"(val) ) ; } This is how I compile it : nasm -f bin -o ./bin/boot.bin ./source/boot.asm gcc -nostdinc -fno-builtin -I./include -c -o ./bin/kernel.o ./source/kernel.c ld -Ttext=0x9000 -o ./bin/kernel.bin ./bin/kernel.o -e 0x0 dd if=/dev/zero of=./bin/empty.bin bs=1440K count=1 cat ./bin/boot.bin ./bin/kernel.bin ./bin/empty.bin|head -c 1440K > ./bin/os rm ./bin/empty.bin and I run it in virtual machine. When I make the putchar function ( in kernel code ) for constant value ....i.e like this: void putchar() { char val = 'A'; asm("movb %0, %%al\n" "movb $0x0E, %%ah\n" "int $0x10\n" : :"r"(val) ) ; } then it works fine. But when I pass argument to it ( That is in the previous code ) , then it prints a space for any character. What should I do?

    Read the article

  • How to do RLE (run length encoding) in C# on a byte array?

    - by CuriousCoder
    I am trying to XOR two bitmap files (their byte arrays) to produce a byte array that can be used to change image A into image B or vice versa. I am sending this over the network so I would like to do some basic compression before this happens. Is there a way to do RLE (run length encoding) in C# (using a built-in, or fast reliable 3rd party library) on a byte array for this purpose? Notes: If you are going to suggest an alternative to my approach please keep in mind that the decompression and transformation on the remote machine has to be as quick and efficient as possible.

    Read the article

  • CSS regression tool?

    - by ronaldwidha
    I'm looking for a visual regression testing tool for CSS refactoring and see whether or not there are any unintended cascading behavior in a website. Ideally, the tool that can crawl a website (even locally) and grab snapshots of each page and store it in a single repository. When run for the second time, it will show the pages that are visually different since the last time it was run. Even better: if it can show the overlapper XOR view of the 2 version of the page. compare rendering results of different browsers (almost like an automated Microsoft Expression Web compare feature). Thanks

    Read the article

  • determine if parity bit representation in MIPS

    - by Hristo
    Is there some instruction in MIPS that will determine the parity of a certain bit representation? I know to determine whether a "number" has an even parity or an odd parity is to XOR the individual bits of the binary representation together, but that seems computationally-intensive for a set of MIPS instructions... and I need to do this as quick as possible. Also, the number I'm working in is represented in Grey Code... just to throw that in there. So is there some pseudo-instruction in MIPS to determine the parity of a "number" or do I have to do it by hand? Thanks, Hristo

    Read the article

  • "call" instruction that seemingly jumps into itself

    - by Checkers
    I have gcc 4 compiling some C++ code into the following (from objdump): 00000030 <func()>: 30: 55 push %ebp 31: 89 e5 mov %esp,%ebp 33: 56 push %esi 34: 31 f6 xor %esi,%esi 36: 53 push %ebx 37: bb 00 00 00 00 mov $0x0,%ebx 3c: 83 ec 40 sub $0x40,%esp 3f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 46: e8 fc ff ff ff call 47 <func()+0x17> 4b: 8d 55 ec lea 0xffffffec(%ebp),%edx 4e: 89 14 24 mov %edx,(%esp) 51: 89 5c 24 04 mov %ebx,0x4(%esp) 55: 89 74 24 08 mov %esi,0x8(%esp) 59: 89 44 24 0c mov %eax,0xc(%esp) ; the rest of the function is omitted I can't understand the operand of call instruction here, why does it call into itself, but with one byte off?

    Read the article

  • One position right barrel shift using ALU Operators?

    - by Tomek
    I was wondering if there was an efficient way to perform a shift right on an 8 bit binary value using only ALU Operators (NOT, OR, AND, XOR, ADD, SUB) Example: input: 00110101 output: 10011010 I have been able to implement a shift left by just adding the 8 bit binary value with itself since a shift left is equivalent to multiplying by 2. However, I can't think of a way to do this for shift right. The only method I have come up with so far is to just perform 7 left barrel shifts. Is this the only way?

    Read the article

  • ASM programming, how to use loop?

    - by chris
    Hello. Im first time here.I am a college student. I've created a simple program by using assembly language. And im wondering if i can use loop method to run it almost samething as what it does below the program i posted. and im also eager to find someome who i can talk through MSN messanger so i can ask you questions right away.(if possible) ok thank you .MODEL small .STACK 400h .data prompt db 10,13,'Please enter a 3 digit number, example 100:',10,13,'$' ;10,13 cause to go to next line first_digit db 0d second_digit db 0d third_digit db 0d Not_prime db 10,13,'This number is not prime!',10,13,'$' prime db 10,13,'This number is prime!',10,13,'$' question db 10,13,'Do you want to contine Y/N $' counter dw 0d number dw 0d half dw ? .code Start: mov ax, @data ;establish access to the data segment mov ds, ax mov number, 0d LetsRoll: mov dx, offset prompt ; print the string (please enter a 3 digit...) mov ah, 9h int 21h ;execute ;read FIRST DIGIT mov ah, 1d ;bios code for read a keystroke int 21h ;call bios, it is understood that the ascii code will be returned in al mov first_digit, al ;may as well save a copy sub al, 30h ;Convert code to an actual integer cbw ;CONVERT BYTE TO WORD. This takes whatever number is in al and ;extends it to ax, doubling its size from 8 bits to 16 bits ;The first digit now occupies all of ax as an integer mov cx, 100d ;This is so we can calculate 100*1st digit +10*2nd digit + 3rd digit mul cx ;start to accumulate the 3 digit number in the variable imul cx ;it is understood that the other operand is ax ;AND that the result will use both dx::ax ;but we understand that dx will contain only leading zeros add number, ax ;save ;variable <number> now contains 1st digit * 10 ;---------------------------------------------------------------------- ;read SECOND DIGIT, multiply by 10 and add in mov ah, 1d ;bios code for read a keystroke int 21h ;call bios, it is understood that the ascii code will be returned in al mov second_digit, al ;may as well save a copy sub al, 30h ;Convert code to an actual integer cbw ;CONVERT BYTE TO WORD. This takes whatever number is in al and ;extends it to ax, boubling its size from 8 bits to 16 bits ;The first digit now occupies all of ax as an integer mov cx, 10d ;continue to accumulate the 3 digit number in the variable mul cx ;it is understood that the other operand is ax, containing first digit ;AND that the result will use both dx::ax ;but we understand that dx will contain only leading zeros. Ignore them add number, ax ;save -- nearly finished ;variable <number> now contains 1st digit * 100 + second digit * 10 ;---------------------------------------------------------------------- ;read THIRD DIGIT, add it in (no multiplication this time) mov ah, 1d ;bios code for read a keystroke int 21h ;call bios, it is understood that the ascii code will be returned in al mov third_digit, al ;may as well save a copy sub al, 30h ;Convert code to an actual integer cbw ;CONVERT BYTE TO WORD. This takes whatever number is in al and ;extends it to ax, boubling its size from 8 bits to 16 bits ;The first digit now occupies all of ax as an integer add number, ax ;Both my variable number and ax are 16 bits, so equal size mov ax, number ;copy contents of number to ax mov cx, 2h div cx ;Divide by cx mov half, ax ;copy the contents of ax to half mov cx, 2h; mov ax, number; ;copy numbers to ax xor dx, dx ;flush dx jmp prime_check ;jump to prime check print_question: mov dx, offset question ;print string (do you want to continue Y/N?) mov ah, 9h int 21h ;execute mov ah, 1h int 21h ;execute cmp al, 4eh ;compare je Exit ;jump to exit cmp al, 6eh ;compare je Exit ;jump to exit cmp al, 59h ;compare je Start ;jump to start cmp al, 79h ;compare je Start ;jump to start prime_check: div cx; ;Divide by cx cmp dx, 0h ;reset the value of dx je print_not_prime ;jump to not prime xor dx, dx; ;flush dx mov ax, number ;copy the contents of number to ax cmp cx, half ;compare half with cx je print_prime ;jump to print prime section inc cx; ;increment cx by one jmp prime_check ;repeat the prime check print_prime: mov dx, offset prime ;print string (this number is prime!) mov ah, 9h int 21h ;execute jmp print_question ;jumps to question (do you want to continue Y/N?) this is for repeat print_not_prime: mov dx, offset Not_prime ;print string (this number is not prime!) mov ah, 9h int 21h ;execute jmp print_question ;jumps to question (do you want to continue Y/N?) this is for repeat Exit: mov ah, 4ch int 21h ;execute exit END Start

    Read the article

  • C question: Padding bits in unsigned integers and bitwise operations (C89)

    - by Anonymous Question Guy
    I have a lot of code that performs bitwise operations on unsigned integers. I wrote my code with the assumption that those operations were on integers of fixed width without any padding bits. For example an array of 32 bit unsigned integers of which all 32 bits available for each integer. I'm looking to make my code more portable and I'm focused on making sure I'm C89 compliant (in this case). One of the issues that I've come across is possible padded integers. Take this extreme example, taken from the GMP manual: However on Cray vector systems it may be noted that short and int are always stored in 8 bytes (and with sizeof indicating that) but use only 32 or 46 bits. The nails feature can account for this, by passing for instance 8*sizeof(int)-INT_BIT. I've also read about this type of padding in other places. I actually read of a post on SO last night (forgive me, I don't have the link and I'm going to cite something similar from memory) where if you have, say, a double with 60 usable bits the other 4 could be used for padding and those padding bits could serve some internal purpose so they cannot be modified. So let's say for example my code is compiled on a platform where an unsigned int type is sized at 4 bytes, each byte being 8 bits, however the most significant 2 bits are padding bits. Would UINT_MAX in that case be 0x3FFFFFFF (1073741823) ? #include <stdio.h> #include <stdlib.h> /* padding bits represented by underscores */ int main( int argc, char **argv ) { unsigned int a = 0x2AAAAAAA; /* __101010101010101010101010101010 */ unsigned int b = 0x15555555; /* __010101010101010101010101010101 */ unsigned int c = a ^ b; /* ?? __111111111111111111111111111111 */ unsigned int d = c << 5; /* ?? __111111111111111111111111100000 */ unsigned int e = d >> 5; /* ?? __000001111111111111111111111111 */ printf( "a: %X\nb: %X\nc: %X\nd: %X\ne: %X\n", a, b, c, d, e ); return 0; } is it safe to XOR two integers with padding bits? wouldn't I XOR whatever the padding bits are? I can't find this behavior covered in C89. furthermore is the c var guaranteed to be 0x3FFFFFFF or if for example the two padding bits were both on in a or b would c be 0xFFFFFFFF ? same question with d and e. am i manipulating the padding bits by shifting? I would expect to see this below, assuming 32 bits with the 2 most significant bits used for padding, but I want to know if something like this is guaranteed: a: 2AAAAAAA b: 15555555 c: 3FFFFFFF d: 3FFFFFE0 e: 01FFFFFF Also are padding bits always the most significant bits or could they be the least significant bits? Thanks guys EDIT 12/19/2010 5PM EST: Christoph has answered my question. Thanks! I had also asked (above) whether padding bits are always the most significant bits. This is cited in the rationale for the C99 standard, and the answer is no. I am playing it safe and assuming the same for C89. Here is specifically what the C99 rationale says for §6.2.6.2 (Representation of Integer Types): Padding bits are user-accessible in an unsigned integer type. For example, suppose a machine uses a pair of 16-bit shorts (each with its own sign bit) to make up a 32-bit int and the sign bit of the lower short is ignored when used in this 32-bit int. Then, as a 32-bit signed int, there is a padding bit (in the middle of the 32 bits) that is ignored in determining the value of the 32-bit signed int. But, if this 32-bit item is treated as a 32-bit unsigned int, then that padding bit is visible to the user’s program. The C committee was told that there is a machine that works this way, and that is one reason that padding bits were added to C99. Footnotes 44 and 45 mention that parity bits might be padding bits. The committee does not know of any machines with user-accessible parity bits within an integer. Therefore, the committee is not aware of any machines that treat parity bits as padding bits. EDIT 12/28/2010 3PM EST: I found an interesting discussion on comp.lang.c from a few months ago. Bitwise Operator Effects on Padding Bits (VelocityReviews reader) Bitwise Operator Effects on Padding Bits (Google Groups alternate link) One point made by Dietmar which I found interesting: Let's note that padding bits are not necessary for the existence of trap representations; combinations of value bits which do not represent a value of the object type would also do.

    Read the article

  • [ebp + 6] instead of +8 in a JIT compiler

    - by David Titarenco
    I'm implementing a simplistic JIT compiler in a VM I'm writing for fun (mostly to learn more about language design) and I'm getting some weird behavior, maybe someone can tell me why. First I define a JIT "prototype" both for C and C++: #ifdef __cplusplus typedef void* (*_JIT_METHOD) (...); #else typedef (*_JIT_METHOD) (); #endif I have a compile() function that will compile stuff into ASM and stick it somewhere in memory: void* compile (void* something) { // grab some memory unsigned char* buffer = (unsigned char*) malloc (1024); // xor eax, eax // inc eax // inc eax // inc eax // ret -> eax should be 3 /* WORKS! buffer[0] = 0x67; buffer[1] = 0x31; buffer[2] = 0xC0; buffer[3] = 0x67; buffer[4] = 0x40; buffer[5] = 0x67; buffer[6] = 0x40; buffer[7] = 0x67; buffer[8] = 0x40; buffer[9] = 0xC3; */ // xor eax, eax // mov eax, 9 // ret 4 -> eax should be 9 /* WORKS! buffer[0] = 0x67; buffer[1] = 0x31; buffer[2] = 0xC0; buffer[3] = 0x67; buffer[4] = 0xB8; buffer[5] = 0x09; buffer[6] = 0x00; buffer[7] = 0x00; buffer[8] = 0x00; buffer[9] = 0xC3; */ // push ebp // mov ebp, esp // mov eax, [ebp + 6] ; wtf? shouldn't this be [ebp + 8]!? // mov esp, ebp // pop ebp // ret -> eax should be the first value sent to the function /* WORKS! */ buffer[0] = 0x66; buffer[1] = 0x55; buffer[2] = 0x66; buffer[3] = 0x89; buffer[4] = 0xE5; buffer[5] = 0x66; buffer[6] = 0x66; buffer[7] = 0x8B; buffer[8] = 0x45; buffer[9] = 0x06; buffer[10] = 0x66; buffer[11] = 0x89; buffer[12] = 0xEC; buffer[13] = 0x66; buffer[14] = 0x5D; buffer[15] = 0xC3; // mov eax, 5 // add eax, ecx // ret -> eax should be 50 /* WORKS! buffer[0] = 0x67; buffer[1] = 0xB8; buffer[2] = 0x05; buffer[3] = 0x00; buffer[4] = 0x00; buffer[5] = 0x00; buffer[6] = 0x66; buffer[7] = 0x01; buffer[8] = 0xC8; buffer[9] = 0xC3; */ return buffer; } And finally I have the main chunk of the program: void main (int argc, char **args) { DWORD oldProtect = (DWORD) NULL; int i = 667, j = 1, k = 5, l = 0; // generate some arbitrary function _JIT_METHOD someFunc = (_JIT_METHOD) compile(NULL); // windows only #if defined _WIN64 || defined _WIN32 // set memory permissions and flush CPU code cache VirtualProtect(someFunc,1024,PAGE_EXECUTE_READWRITE, &oldProtect); FlushInstructionCache(GetCurrentProcess(), someFunc, 1024); #endif // this asm just for some debugging/testing purposes __asm mov ecx, i // run compiled function (from wherever *someFunc is pointing to) l = (int)someFunc(i, k); // did it work? printf("result: %d", l); free (someFunc); _getch(); } As you can see, the compile() function has a couple of tests I ran to make sure I get expected results, and pretty much everything works but I have a question... On most tutorials or documentation resources, to get the first value of a function passed (in the case of ints) you do [ebp+8], the second [ebp+12] and so forth. For some reason, I have to do [ebp+6] then [ebp+10] and so forth. Could anyone tell me why?

    Read the article

  • Using an array in embedded x86 assembly??

    - by Mark V.
    Hey all I have a method (C++) that returns a character and takes an array of characters as its parameters. I'm messing with assembly for the first time and just trying to return the first character of the array in the dl register. Here's what I have so far: char returnFirstChar(char arrayOfLetters[]) { char max; __asm { push eax push ebx push ecx push edx mov dl, 0 mov eax, arrayOfLetters[0] xor edx, edx mov dl, al mov max, dl pop edx pop ecx pop ebx pop eax } return max; } For some reason this method returns a ? Any idea whats going on? Thanks

    Read the article

  • Redundancy algorithm for reading noisy bitstream

    - by Tedd Hansen
    I'm reading a lossy bit stream and I need a way to recover as much usable data as possible. There can be 1's in place of 0's and 0's in palce of 1's, but accuracy is probably over 80%. A bonus would be if the algorithm could compensate for missing/too many bits as well. The source I'm reading from is analogue with noise (microphone via FFT), and the read timing could vary depending on computer speed. I remember reading about algorithms used in CD-ROM's doing this in 3? layers, so I'm guessing using several layers is a good option. I don't remember the details though, so if anyone can share some ideas that would be great! :) Edit: Added sample data Best case data: in: 0000010101000010110100101101100111000000100100101101100111000000100100001100000010000101110101001101100111000101110000001001111011001100110000001001100111011110110101011100111011000100110000001000010111 out: 0010101000010110100101101100111000000100100101101100111000000100100001100000010000101110101001101100111000101110000001001111011001100110000001001100111011110110101011100111011000100110000001000010111011 Bade case (timing is off, samples are missing): out: 00101010000101101001011011001110000001001001011011001110000001001000011000000100001011101010011011001 in: 00111101001011111110010010111111011110000010010000111000011101001101111110000110111011110111111111101 Edit2: I am able to controll the data being sent. Currently attempting to implement simple XOR checking (though it won't be enough).

    Read the article

  • how can c# help in drawing using memory layers concept?

    - by moon
    hello all i am facing problem in drawing dynamically in a picture box. i works very good when the drawing objects are few but as the drawing objects increases the response time of my GUI is getting worse and worse, my GUI works very well up to 90 drawing objects but i have to support more than 1000 so this technique didn't work for me. know i have decided to adopt layers mechanism, i mean i will draw different layers of drawing in memory and then XOR them to load the final image to my display. the question is "i Can play directly with memory do draw layers using C# (Examples needed?)" other ideas are also appreciated, (Drawing objects means the shapes line,circles etc. that i have to draw on my GUI) thanx in advance

    Read the article

  • xCode complitions, spelling checkings stoped

    - by SentineL
    My xCode 4.3.2 stopped to show up spelling errors and completions for code. The only way to find out if there is any error in the code - build it. xCode colores only keywords such as if, else, for etc. All other code hasn't colored. Shown only a few very strange completions. For example: CGPoint p; p.y // complition is "YES" p.x // complition is "xor" Completions for methods calls are only nearaly used methods. How can I fix this? I rebooted my mac several times allready, and didn't find any staff obout this in xCode's preferences.

    Read the article

  • Generate a commutative hash based on three sets of numbers?

    - by DarkAmgine
    I need to generate a commutative hash based on three sets of "score" structs. Each score has a "start", an "end" and a "number". Both start and end are usually huge numbers (8-9 digits) but number is just from 1 to 4. I need them to be commutative so the order does not matter. I'm using XOR at the moment but it seems to be giving bad results. Since I'm working with large large datasets, I'd prefer a performance-friendly solution. Any suggestions? Thanks =] public static int getCustomHash(cnvRegion c1, cnvRegion c2, cnvRegion c3) { int part1 = (c1.startLocation * c2.startLocation * c3.startLocation); int part2 = (c1.endLocation * c2.endLocation * c3.endLocation); int part3 = (c1.copyNumber + c2.copyNumber + c3.copyNumber)*23735160; return part1 ^ part2 ^ part3; }

    Read the article

  • What is the most efficient algorithm for reversing a String in Java?

    - by Hultner
    I am wondering which way to reverse a string in Java that is most efficient. Should I use some sort of xor method? The easy way would be to put all the chars in a stack and put them back into a string again but I doubt that's a very efficient way to do it. And please do not tell me to use some built in function in Java. I am interested in learning how to do it not to use an efficient function but not knowing why it's efficient or how it's built up.

    Read the article

  • CRC32 calculations for png chunk doesn't match the real one

    - by user2507197
    I'm attempting to mimic the function used for creating CRC's in PNG files, I'm using the autodin II polynomial and the source code from: http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/libkern/crc32.c My tests have all been for the IHDR chunk, so my parameters have been: crc - 0xffffffff and 0 (both have been suggested) buff - the address of the IHDR Chunk's type. length - the IHDR Chunk's length + 4 (the length of the chunk's data + the length of the type) I printed the calculated CRC in binary, which I compared to the actual CRC of the chunk. I can see no similarities (little-big endian, reversed bits, XOR'd, etc). This is the data for the IHDR chunk (hexadecimal format): length(big endian): d0 00 00 00 (13) type: 49 48 44 52 data: 00 00 01 77 00 00 01 68 08 06 00 00 00 existing CRC: b0 bb 40 ac If anyone can tell me why my calculations are off, or give me a CRC32 function that will work I would greatly appreciate it. Thank-you!

    Read the article

  • Passing operator as a parameter

    - by nacho4d
    Hi, I want to have a function that evaluates 2 bool vars (like a truth table) for example: since T | F : T then myfunc('t', 'f', ||); /*defined as: bool myfunc(char lv, char rv, ????)*/ should return true; how can I pass the third parameter? (I know is possible to pass it as a char* but then I will have to have another table to compare operator string and then do the operation which is something I would like to avoid) Is it possible to pass an operator like ^(XOR) or ||(OR) or &&(AND), etc in a function/method? Thanks in advance

    Read the article

  • Construction an logical expression which will count bits in a byte.

    - by danatel
    When interviewing new candidates, we usually ask them to write a piece of C code to count the number of bits with value 1 in a given byte variable (e.g. the byte 3 has two 1-bits). I know all the common answers, such as right shifting eight times, or indexing constant table of 256 precomputed results. But, is there a smarter way without using the precomputed table? What is the shortest combination of byte operations (AND, OR, XOR, +, -, binary negation, left and right shift) which computes the number of bites?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >