Consider a code excerpt below:
typedef struct tagTHREADNAME_INFO {
DWORD dwType;
LPCTSTR szName;
DWORD dwThreadID;
DWORD dwFlags;
} THREADNAME_INFO;
const THREADNAME_INFO info = { 0x1000, threadName, CurrentId(), 0};
::RaiseException(kVCThreadNameException, 0,
sizeof(info) / sizeof(ULONG_PTR),
(ULONG_PTR*)&info...
Hello,
I find myself in need of performing bit-level conversion on variables in PHP. In more detail, I have a bit stream that is read as an integer by hardware, and I need to do some operations on the bits to make it into what its actually supposed to be (a float). I have to do this a few times for different formats, and the functionali...
I have am getting an error when I try and alter a date column:
Arithmetic overflow error for type varchar, value = 20100601.000000.
I would like it to go from float to the datetime format of 20100601.
Since Alter doesn't work, how can I use cast or convert to change the datatype for every entry in the table?
...
I want:
111 || 100 ---> 111, not 1
100 && 100 ---> 100, not 1
101 && 010 ---> 000, not 0
Broken code
#include <stdio.h>
main(void){
string hexa = 0xff;
strig hexa2 = 0xf1;
// CONVERT TO INT??? cast
int hexa3 = hexa || hexa2;
int hexa4 = hexa && hexa2;
puts(hexa3);
puts(...
I am porting some C++ code to GCC, and apperantly it isn't happy with C++ style casting when sapces are involved, as in unsigned int(-1), long long(ShortVar) etc... It gives an error: expected primary-expression before 'long'.
Is there any way to make peace with GCC without going over each one of those and rewrite in c-style?
...
I need to write a Util function (in my c++cli app) that converts a String to a Double or Float or Int.
template<typename T>
static T MyConvert(String^ str) {
return static_cast<T>(System::Convert::ToDouble(str));
}
Is this safe?
Can it somehow convert 2 to 1.999 and then to 1 if I call MyConvert<int>("2") ?
I was wondering why th...
Code to illustrate :
int i = 5;
object obj = i;
byte b = (byte)obj; // X
When run, this generates a System.InvalidCastException ("Specified cast is not valid") at line "X". Doing a double cast works :
byte b = (byte)(int)obj;
I would have thought that you ought to be able to cast a boxed int (if it ...
Hi
coming from this question "What does (int (*)[])var1 stand for?" I tried to access the result of the cast like a multidimensional array. But I get following error: "assignment from incompatible pointer type" followed by a segmentation fault. I tried also some other variations, but none of them worked. How can I access the elements in...
Hi! I need a fast way in C# leanguage of converting/casting array of bytes encoding one short (int16) value for 2bytes into float representation, as fast as possible. Performance bottleneck was method:
samples[sample] = (float)binraryReader.readInt16();
(huge ammount of IO calls so i had to convert to block read)
Basically i have fil...
I've got some data access layer code calls a stored proc and returns scalar values of various datatypes. The syntax is ExecuteDecimal, ExecuteString, etc. I want it to be Execute<string> or Execute<decimal>
I try this implementation and I can't compile, unless I'm doing casting using "(T) value", if I try to check the type and call a ...
While optimizing a function in PHP, I changed
if(is_array($obj)) foreach($obj as $key=>$value { [snip] }
else if(is_object($obj)) foreach($obj as $key=>$value { [snip] }
to
if($obj == (array) $obj) foreach($obj as $key=>$value { [snip] }
else if($obj == (obj) $obj) foreach($obj as $key=>$value { [snip] }
After learning about ==...
I forgot casting mechanism when i encounter it :) . So can u make me remember it again ? Because it looks not acceptable for me at the moment.
...
Can you cast an object to one that implements an interface? Right now, I'm building a GUI, and I don't want to rewrite the Confirm/Cancel code (A confirmation pop-up) over and over again.
So, what I'm trying to do is write a class that gets passed the class it's used in and tells the class whether or not the user pressed Confirm or Canc...
For simplicity,
class Parent {}
class Child1 : Parent {}
class Child2 : Parent {}
Elsewhere, I created instances of Child1 and Child2 and store it in same vector under Parent:
// . . . in .h file, for example
vector<Parent> vector_of_parent;
// . . . in one particular method
Child1 c1;
Child2 c2;
vector_of_parent.push_back(c1);
ve...
Hello !
When I try to cast
$value = floatval('14,5833');
to a float type I expect a value with dot like 14.5833 but it returns me 14,5833.
How should I do this ?
I wouldn't like to use any string replace functions.
...
I am developing asp.net web service. I am developing this web service so that OPC ( OLE for process control) client application can use it. In this web service I am using the built-in functions provided by the namespaces using OPC, using OPCDA, using OPCDA.NET. I have also added the namespace using System.Windows.Forms in this web servi...
I am currently working on a game "engine" that needs to move values between a 3D engine, a physics engine and a scripting language. Since I need to apply vectors from the physics engine to 3D objects very often and want to be able to control both the 3D, as well as the physics objects through the scripting system, I need a mechanism to c...
I'm not understanding something about the way .Cast works. I have an explicit (though implicit also fails) cast defined which seems to work when I use it "regularly", but not when I try to use .Cast. Why? Here is some compilable code that demonstrates my problem.
public class Class1
{
public string prop1 { get; set; }
public ...
I want to cast the const-ness out of a boost::shared_ptr, but I boost::const_pointer_cast is not the answer. boost::const_pointer_cast wants a const boost::shared_ptr, not a boost::shared_ptr. Let's forego the obligitory 'you shouldn't be doing that'. I know... but I need to do it... so what's the best/easiest way to do it?
For clari...
I'm doing programming of a softcore processor, Nios II from Altera, below is the code in one of the tutorial, I manage to get the code working by testing it on the hardware (DE2 board), however, I could not understand the code.
#define Switches (volatile char *) 0x0003000
#define LEDs (char *) 0x0003010
void main()
{ while (1)
*LEDs = *...