Say I have code like this... typedef struct { unsigned A:1; unsigned B:1; } FlagStruct; extern FlagStruct *Flags; Imagine that the Flags instance is a shared resource in a multi-threaded application. Say thread #1 decides to read the value of Flags->A but thread #2 decides to set or clear Flag->B at the exact same time. How isolated is Flag->A from Flag->B such that any changes to Flag->B does not affect the value of Flag->A? In other words, are set or clear operations in this structure atomic and therefore thread safe?

Member Avatar
Member Avatar
+0 forum 4

// random number generator var theDecimal = 0; function newProblem(){ theDecimal = Math.floor(Math.random()*256); //math.floor chops off decimals and rounds document.getElementById("startNumber").innerHTML = theDecimal; }

Member Avatar
Member Avatar
+0 forum 2

Hi there, I have an array of unsigned chars SOURCE, i need to combine into DESTINATION, i want to turn: SOURCE[0] = 3 SOURCE[1] = 9 SOURCE[2] = ' ' SOURCE[3] = 0 SOURCE[4] = 4 SOURCE[5] = ' ' SOURCE[6] = 7 SOURCE[7] = d into DESTINATION[0] = 39 DESTINATION[1] = 04 DESTINATION[2] = 7d Any ideas Many Thanks

Member Avatar
Member Avatar
+0 forum 12

void Project1(){ unsigned short int x; bool flag = false; cout << "Enter an interger, I will reversed i.e. 301 --> 103" << endl; cin >> x; if ((x > 0) && (x <= 65535) ){ flag == true; cout << reverse_num(x); cout << endl; } else { cout << "No conversion possible." << endl; } } I having trouble when i enter a number out of the range of unsigned short int

Member Avatar
Member Avatar
+0 forum 3

Hello. I've been doing a small application that will go (using only unsigned integer values) from 0 to 4026531840 and print them out. My code is next: [CODE]#include <stdio.h> #include <inttypes.h> int main(void){ uint64_t cnt; for(cnt=0;cnt<=4026531840;cnt++){ printf("%d\n",cnt); } } [/CODE] The only problem that i have is the last numbers are negative (the really last one is -268435456). I also tried using: [CODE]#include <stdio.h> int main(void){ unsigned long long int cnt; for(cnt=0;cnt<=4026531840;cnt++){ printf("%d\n",cnt); } } [/CODE] but the problem persists. I'm using gcc: Target: x86_64-linux-gnu gcc version 4.6.1 (Debian 4.6.1-4) on my linux machine: Linux mysql 3.0.0-1-amd64 #1 SMP Sat …

Member Avatar
Member Avatar
+0 forum 2

Before you read, I am using Mac's Xcode. In this program I am attempting to print the maximum and minimum values of standard C variables with every variation of modifiers. The unsigned int uses 4 bytes therefore it must have a maximum value of 4294967296 but it only display 2147483647 as its maximum value. My goal is to have xcode print an unsigned integers maximum value which is 4294967296; am I doing anything incorrectly in the program? You can focus on the second line of variables declared in main() and the last 2 printf functions. [ICODE] #include <stdio.h> #include <stdbool.h> …

Member Avatar
Member Avatar
+0 forum 8

This is a conversion question that has me stumped. I need to convert an unsigned char to a signed float. Some examples: 0xFF becomes 1.0f 0x00 becomes -1.0f 0x80 becomes ~0.0f The only idea that I could come up with was a massive switch statement. But a switch statement will be slow and I need this to run fast. Any ideas?

Member Avatar
Member Avatar
+0 forum 2

The End.