|
How can I use such large numbers in C or C++?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
The only thing that pops into mind is to use BCD arithmetic, though I haven't used it in almost two decades and then it was purely for academic reasons.
(I looked at your birthday. I haven't used BCD arithmetic since before you were born )
Joe Woodbury
When all else fails, there's always delusion.
- Conan O'Brien
|
|
|
|
|
BCD arithmetic, okay, I'll Google for it!
Tackar!
Danke!
Thanks!
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
One solution is to check out freeware math libraries. Check out CodeProject code section and CodeGuru.
Kuphryn
|
|
|
|
|
I am trying to write a program that generates track lists for music cd's. If the cd that the user has in the drive has been written with the track names etc on the disk, I want to be able to read this information from the cd.
I have no idea how to go about this . can someone help??!!
|
|
|
|
|
i think u want to be looking at the extended orange book format
"there is no spoon" biz stuff about me
|
|
|
|
|
use CDDB!
Don't try it, just do it!
|
|
|
|
|
Hello,
I want to do something whenever on of the header columns in my CListView changes in size.
For that I catch the HDN_ITEMCHANGED message. But that one is not fired in the CListView.
What I have is a message entry:
ON_NOTIFY_REFLECT(HDN_ITEMCHANGED, OnItemchanged)
I've read the article by Matt Damon 'Using the CHeaderCtrl', and he mentions something about that, but the article is based on the CListCtrl, not the CListView, so the workaroud doesn't seem applicable for me.
Anyone knows how this message is fired in the CListView?
Thanks
Wim
|
|
|
|
|
WM_NOTIFY messages are sent by a control to its parent. So HDN_* messages are sent from the header to the list. Therefore, ON_NOTIFY_REFLECT is the wrong macro to use since the message isn't sent by the list. (That would be right if you were trying to handle, say LVN_ITEMCHANGED )
Use regular ON_NOTIFY .
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
CP SearchBar v2.0.2 released
|
|
|
|
|
Thanks Michael,
That worked like a charm
Regards
Wim
|
|
|
|
|
Hi all,
I am currently designing a plug-in architecture and I am looking for advice on how to go about sending messages to a given plug-in or all plug-ins. I would be sending messages for keypresses, mouse clicks, etc.
Thanks,
Steve
|
|
|
|
|
If your working on an MFC program, I have a library that allows plug-ins here http://www.codeproject.com/library/piarchitecture.asp[^]
That handles all the kind of stuff your talking about.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Roger,
Thanks, I did't think to look in the library section... but thanks I will have a look
Steve
|
|
|
|
|
Roger,
This is overwhelming. Do you have an example project using a dialog application. I don't need hardly any of what your library is doing. I am only using a dialog base application and all the plug-ins will be dialog based as well.
Thanks,
Steve
|
|
|
|
|
i wrote:
m_DLG.m_rate = recordset.GetFieldValue("rate").dblVal;
even though my m_rate is a float type, when i compile i get the error warning C4244: '=' : conversion from 'double' to 'float', possible loss of data.
i tried to use fltVal and other database conventions but the values will appear distorted. although i get this warning, the data value appear correctly when just wanna knoe if can resolve this.
|
|
|
|
|
|
Try Casting the value type:
m_DLG.m_rate = (float)(recordset.GetFieldValue("rate").dblVal);
This should convert the double to a float making the assignment acceptable to the compiler. Note it is possible to lose accuarcy of the information as float has smaller limits than double.
|
|
|
|
|
thanx! the compiler accepts it now
|
|
|
|
|
i wrote:
m_DLG.m_rate = recordset.GetFieldValue("rate").dblVal;
even though my m_rate is a float type, when i compile i get the error warning C4244: '=' : conversion from 'double' to 'float', possible loss of data.
i tried to use fltVal and other database conventions but the values will appear distorted. although i get this warning, the data value appear correctly when jua wanna knoe if can resolve this.
|
|
|
|
|
a) recordset.GetFieldValue("rate") gives a variable of variant type, which means that it can hold a value of one of a set of types. The type it actually hold is in the .vt member. If you access the wrong one for the type, then it comes out as garbage (for reasons why, take a look at the union construct).
b) .dbvVal returns a double , yet your m_rate is a float . float variables take up a smaller size than double (in VC++, float is 4 bytes, double is 8) - this means that some of the precision of the double is lost in the converstion to float .
So you need to check the type of the variant before accessing it, and you need to store the result in an appropriately typed variable, or cast it.
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
Ian Darling wrote:
So you need to check the type of the variant before accessing it, and you need to store the result in an appropriately typed variable, or cast it.
Or there's always VariantChangeType[^].
|
|
|
|
|
I want to analyze C++ source code(VC) and Java source code. To know classes relationship. How to use yacc and lex to do this? Have any C++ parse or Java parse for this purpose?
|
|
|
|
|
Ah, something on which I have experience
In the final year of my degree, I had to select an individual project. One of the projects offered was to produce an application to draw diagrams of the static structure of an input program - I selected this project.
Subsequently I discovered that it's extremely hard to write a C++ parser. A Java parser isn't a lot easier. My difficulties in writing the parser basically meant that the rest of the application never got written, and I damn near failed the project.
Anyway, while trying to write it, I posted numerous questions and progress reports on various Usenet newsgroups. The best way to read it all is to Google[^] for it.
See also http://www.nobugs.org/developer/parsingcpp/[^].
Since then, I've come to the opinion that you should use the most powerful tools possible when parsing C++ - ones that cope with the ambiguity inherent in the language. The general name for this type of tool is a 'Generalised LR' parser - often abbreviated GLR. Elkhound[^] looks quite interesting.
As for me, I'm steering well clear of parsing for the meantime. I think the understanding of C++ I got from trying to parse it was quite helpful, anyway.
For either language, you'll want to get hold of the appropriate specification. For Java, the specification is The Java Language Specification[^]. For C++, it's ISO 14882[^] (which has rocketed in price - this used to be $18! - although you may find a copy on the web somewhere.)
|
|
|
|
|
Mike Dimmick wrote:
One of the projects offered was to produce an application to draw diagrams of the static structure of an input program
Wow. Your lecturer must've really had a sense of humour
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.2 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Taka Muraoka wrote:
Your lecturer must've really had a sense of humour
The irony being that he was the lecturer teaching the Programming Language Implementation course (i.e. the how-to-build-a-compiler course).
The set work for that course involved writing a compiler for an extremely simple language which could be parsed quite easily with a recursive-descent LL(1) algorithm, unlike virtually every practical high-level language ever created.
Pascal and Ada can be parsed with a slightly fudged LL(1) parser (Ada has a .. operator which requires the lexer to distinguish between 5.2 as a single floating point literal, or 5..2 as the separate tokens int-literal double-dot-operator int-literal) but programmers used to C++ tend to hate such languages, because there are keywords everywhere.
Much as C++ is hard to parse for computers, and sometimes for humans, if we limit ourselves to simple uses of the syntax, it's often quite quick to express a particular algorithm. I find I'm more productive in expressing an algorithm in C++ than I am in Visual Basic, for example - less to type. However, the GUI libraries are generally not so easy to use from C++.
Having said that, the GUI libraries in C++ usually have far more power - if you need to do something differently from how VB does it, it's much harder. I suppose you could say that in C++, we have a steeper initial learning curve but it requires less effort to add something harder, while with other tools you have a shallower initial curve, but then practically hit a brick wall.
|
|
|
|