|
Richard MacCutchan wrote: This is simple mathematics
it really isn't.
try it in a compiler.
|
|
|
|
|
Chris Losinger wrote: try it in a compiler.
int i = -20;
unsigned int j = 10;
int k = i + j;
answer is -10. However if I just print the value (i + j) it returns 4294967286 obviously an unsigned integer, so some interesting automatic casting going on. I stand corrected!
[edit]the answer is -10 of course![/edit]
MVP 2010 - are they mad?
modified on Friday, January 15, 2010 12:50 PM
|
|
|
|
|
I guess this should be correct: i + j = -20 + 10 = -10
|
|
|
|
|
I noticed the "Joke" icon. I give you a 5.
It is tricky so I think the original post is a pretty good beginner's question. My daughter asks "why" a lot. It's a learning process.
|
|
|
|
|
antionette wrote: int i=-20;
unsigned j=10;
Fine.
antionette wrote: i+j=?
The above doesn't compile.
antionette wrote: And why?
Because it is not a valid C statement.
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]
|
|
|
|
|
antionette wrote: i+j=?
that's actually a tricky question. there are a lot of (really strange and non-intuitive, IMO) rules about how mixed signed/unsigned math is done in C. and a lot of those rules depend on how your compiler interprets the standard, and which standard.
i've found that whenever i'm doing signed/unsigned arithmetic, it's best to cast everything to a signed value, then perform the arithmetic. if the result needs to be unsigned, then i range-check the value to make sure it's non-negative and small enough to fit the result.
in this case, the answer is a huge positive integer.
int i = -20;
unsigned j = 10;
__int64 k = i + j;
k = 4294967286
modified on Friday, January 15, 2010 11:22 AM
|
|
|
|
|
Good info - I think the general rule is: don't use unsigned numbers in calculations.
MVP 2010 - are they mad?
|
|
|
|
|
Richard MacCutchan wrote: Good info - I think the general rule is: don't use unsigned numbers in calculations.
Don't mix unsigned and signed numbers, without proper explicit casts, in calculations.
FFY.
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]
|
|
|
|
|
I use custom draw in report view list controls to alternate the background colour of each row to make it easier to read. This works fine. I've just started an application which would benefit from using groups in list controls. Ok, didn't take too much effort to get this working. The only problem now though is that the row background colours don't alternate any more - I get the same colour together for some adjacent rows.
I have found that in group mode the index of each row no longer refers to the physical position on the screen, the index of each row can in fact be anything! [within the total number] So I can no longer use the index to work out which background colour each row should be.
For example, with 5 items in a group of 4 and a group of 1, when I load the data the indexes are 0, 1, 2, 3, 4. When I sort the first column in reverse order the indexes become 1, 2, 3, 4, 0. The more rows I have the more random it gets.
Any ideas how I can work out what is the visible index?
|
|
|
|
|
You may need to tag your messages with an ID and use the LVM_MAPIDTOINDEX[^] message; there are various other associated messages that should help.
MVP 2010 - are they mad?
|
|
|
|
|
That doesn't help; LVM_MAPINDEXTOID is just used to tell which item it is. It does not give the physical position on the screen.
|
|
|
|
|
Keith Worden wrote: LVM_MAPINDEXTOID is just used to tell which item it is.
Yes, but I suggested LVM_MAPIDTOINDEX , under which the documentation states:
If you need the index of an item after an ID is created you can call LVM_MAPIDTOINDEX with the unique ID and it returns the most current index.
MVP 2010 - are they mad?
|
|
|
|
|
Yes it gives an index but this is just the internal index, it is not the position on the screen. When group mode is off the index and the physical position are the same thing. When group mode is on there is no relationship (that I can find) between them.
|
|
|
|
|
OK, I thought there was also a message that gets you the first visible entry and then you could index from that point to go down the window.
MVP 2010 - are they mad?
|
|
|
|
|
There is the LVM_GETTOPINDEX message, but this always returns zero when group mode is enabled (it's for the topmost visible item anyway, not the first in the list). There's nothing to iterate over the list in the order it's displayed in group mode.
|
|
|
|
|
Hi All,
I want to develop an 3D Image rendering software using DirectX which can perform some 3D Operations.My customer wants the software developed on .Net Framework.
I have experience in coding in MFC in VC6.0.If i develop an MFC based application in Visual Studio 2008,will it be built on .Net Framework?
Thanking in advance,
Ashwath.
|
|
|
|
|
Can you explain why you felt the need to re-post the same exact question just 2 hours after you posted the original question instead of continuing the discussion ?
I'm genuinely curious.
Thanks for taking the time to answer that.
M,
This signature was proudly tested on animals.
|
|
|
|
|
Sorry maxi for reposting ,i will not do it again.Actually as i was not getting answer to my previous post because of lots of questions in it ....i reposted it with only one question.
|
|
|
|
|
No.
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]
|
|
|
|
|
Quit spamming the board. You've already asked your question. Do you think people are going to be more inclined to answer now?
L u n a t i c F r i n g e
|
|
|
|
|
Using VC++(MFC) in Visual Studio 2008 is called unmanaged. Built on .Net framework is called managed. They are totally different.
I think it is a good timing for you to switch to C# now.
|
|
|
|
|
Hello,
Can any body give me the idea how to extract information from win 32 dll's.
e.g
class name
all methods which dll exports.
name of methods, parameter types(in,out) & return type of that method.
all variables (private,public,protected).
all data structures listed
we can do the same job from tlb file which's generated from idl which stores all COM exposed interfaces,co-classes,records,enums and etc..
MS provided TypeLib for this purpose. but from DLl perspective can we do the same job as we can do from tlb using ITypeLib of MS.
Regards
Muhammad Usman Khalil
|
|
|
|
|
If a DLL expose all the information you want, where is abstraction in it?
Then whats the difference of providing a code and DLL?
As far a i think,
you can get the exports and imports of a DLL by parsing the PE file programmatic ([^])
well dependency walker avail with Visual studio is finished product that will be useful for the purpose to get information about the methods.
But regarding the parameters, variables, cannot be extracted from the DLL without the code.
Well whats the use for you, to do so?
Величие не Бога может быть недооценена.
modified on Friday, January 15, 2010 7:43 AM
|
|
|
|
|
What OLEView do with TLB files : parse them, extract every single info(e.g methods,parameter names,their nature in/out, all interfaces types dispinterfaces or simple interfaces, modules and records etc..)
Same information want to extract from win32 dll's. But as win dlls always not generate tlb file or idl file, so how does the way to go..?
Regards
|
|
|
|
|
The TLB 'equivalent' of a standard DLL is its header file.
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]
|
|
|
|