|
DECIMAL is a struct defined in Wtypes.h, the (commented out) simple definition is:
typedef struct tagDEC
{
USHORT wReserved;
BYTE scale;
BYTE sign;
ULONG Hi32;
ULONGLONG Lo64;
} DECIMAL;
So it can represent a signed 96 bits integer with fixed decimal point.
OleAuto.h provides methods to transfer values from C++ numeric types to/from decimal structs such as WINOLEAUTAPI VarR8FromDec( const DECIMAL *pdecIn, DOUBLE *pdblOut); (converts a DECIMAL to DOUBLE) and WINOLEAUTAPI VarDecFromR8(DOUBLE dblIn, DECIMAL *pdecOut); (converts a DOUBLE to DECIMAL);
To use it include Wtypes.h and OleAuto.h, for arithmetic on DECIMAL use the VarDecXXX() functions described at http://msdn.microsoft.com/en-us/library/ms221612.aspx[^].
cheers,
ARWhen the wise person points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Hi
How to convert CString to char#sanroop#
|
|
|
|
|
char a = myString.GetAt(0);
|
|
|
|
|
CString may have more than one character stored in its internal string array. How do you expect to "convert" it to a char ?!
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
hello
i want to define a vector with three or more parameter in space and as i know vector of stl only gets one parameter ,is there any header in stl or other library to solve this?
also i have an array of points and i want to sort them on one axis ,how i can sort it with sort() of stl without any change to points?
for example i used map for 2 dimension :map<int,int> but when i set for example 11,12 11,13 it is false.
thanks in advance.
|
|
|
|
|
struct point3D
{
double x;
double y;
double z;
};
std::vector<point3D> my_vector_of_points;
?
bool sortOnX(const point3D& a, const point3D& b)
{
return a.x < b.x;
}
std::sort(my_vector_of_points.begin(), my_vector_of_points.end(), sortOnX)
|
|
|
|
|
|
Hi,
How could I change the
CMFCPropertyGridCtrl Property or Value column width?
a sample code would be more useful
|
|
|
|
|
somehow late, but here you are:
class CMyPropertyGridCtrl : public CMFCPropertyGridCtrl
{
public:
int SetFirstColumn(int iwidth){ m_nLeftColumnWidth = iwidth;
AdjustLayout();return 0;};
};
...
{
...
CMyPropertyGridCtrl blah;
int iwidth;
blah.SetFirstColumn(iwidth);
...
}
...
|
|
|
|
|
failed
Best Regards
|
|
|
|
|
Hi,
Does anyone know of a class in c++ or a workaround to the following problem when using the atof function?
I'm reading strings of values from an input file, then parsing the string into several substrings.
Then I take the substrings and attempt to convert them to doubles using atof. It works great most of the time, but everynow and then the atof function can't exactly represent a value and you may get "9.199999999999999" instead of the exact value in the string which is "9.2", or "0.5520000000000001" instead of "0.552".
Also, I can't just set the precision because some of the substrings may contain integers or doubles with a varying number of decimal places (ex. "9" or "9.321").
Any ideas?
Thanks,
modified on Friday, March 19, 2010 10:14 AM
|
|
|
|
|
real numbers stored in binary are an approximation of strings represented in decimal, or vice versa; your system cannot easily represent 2/3 nor 1/10 accurately. The best you can do is:
- convert strings to reals, and live with the outcome;
- perform real operations on them;
- output to decimal strings with a specified precision.
And of course, if logic dictates (e.g. rounding rules in finance) use a rounding function.
|
|
|
|
|
Hi ,
I had developed one MSI for my application. In this MSI, I add custom action by calling EXE to display message. When I run this MSI , my custom message is pop up before the Close button of last screen.But I want to show message after user click on Close button of last screen.
If any body know regarding this, please reply to me.
|
|
|
|
|
You must put the EXE as a custom action appearing after the "setup complete" dialog.
How did you develop the MSI, what application did you use?
|
|
|
|
|
struct myStruct {
int x;
int y;
char ch[10];
};
struct myOtherStruct {
int y;
char ch[10];
int x;
};
class myClass {
public:
myClass() { };
~myClass() { };
void someMethod(int x) { ; };
private:
int a;
int b;
char ch[10];
};
int main() {
myStruct s1;
myOtherStruct s2;
myClass c;
return 0;
};
Given these struct/class definitions, is it always safe to assume:
<br />
&s1.x < &s1.y < &s1.ch<br />
&s2.y < &s2.ch < &s2.x<br />
&c.a < &c.b < &c.ch<br />
(Considering the addresses as numbers, like you'd get from (__int64)&s1.x )
Maybe an easier way to ask this is, "Is the order of the members in memory the same as the order in which they are declared?"
Thanks in advance for any help you guys can offer!
|
|
|
|
|
Yes, AFAIK.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Mike the Red wrote: Is the order of the members in memory the same as the order in which they are declared?
No, absolutely not. Without additional information, any compiler can do as it pleases, as long as it is consistent. Here are two typical approaches:
1. reorder the items according to element size, possibly reducing struct size: since items want to be "naturally aligned" (i.e. a N-byte quantity starts at an address that is a multiple of N for best performance) it may pay off to put the largest ones first.
2. keep the declaration order and pad with dummy bytes to achieve natural alignment.
Not a single strategy is good for all purposes as one may want compatibility with another language, an existing data structure in a file, a set of registers in a hardware device, etc.
Hence, most compilers have switches and/or pragma's to control the exact behavior. You should read the documentation of your tools.
|
|
|
|
|
C++ standard says that ordering of variables with in a single access block must be in the order they appear but different blocks can be arranged in arbitrary order. For example:
class Foo
{
public:
int x;
int y;
private:
int _x;
int _y;
};
address of x < address of y
address of _x < address of _y
But you cannot determine relation between address of x and _x. Compiler is free to place then in any order.
-Saurabh
|
|
|
|
|
I don't think so. Can you provide a link to the section that says so?
|
|
|
|
|
Okay I admit I made the comment based on excellent book "Inside the C++ Object Model".
But I check the C++ standard and it is there in Section 9.2 point 12:
"Nonstatic data members of a (non-union) class declared without an intervening access-specifier are allocated so that later members have higher addresses within a class object. The order of allocation of non-static data members separated by an access-specifier is unspecified (11.1). Implementation alignment requirements might cause two adjacent members not to be allocated immediately after each other; so might requirements for space for managing virtual functions (10.3) and virtual base classes (10.1)."
and Section 11.1 point 3:
"The order of allocation of data members with separate access-specifier labels is unspecified (9.2)."
-Saurabh
|
|
|
|
|
Thanks.
So it says it is not always safe to assume the order is preserved.
That is what I remembered, however I didn't know the exceptions were documented as well.
|
|
|
|
|
In the example the OP submitted it is always safe. If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
"always" and "example" indicate an interest in the general answer, covering a broad domain.
|
|
|
|
|
Please don't cheat, his question is actually very well defined. If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|