|
Ok I'll try it ..
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Giorgi Moniava wrote: The four public functions(add,mul,div,sub) were declared as friend functions.
How does declaring them as friend help performance? Declaring them inline is a reasonable decision, though it's still up to the compiler to honour your directive.
Whatever you do, don't forget to measure. First code for readability and intuitiviness, measure the performance and if it's not upto the mark, you can then worry about minor adjustments.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote: How does declaring them as friend help performance
I did not say that...
S. Senthil Kumar wrote: First code for readability and intuitiviness, measure the performance and if it's not upto the mark, you can then worry about minor adjustments.
In this case my main point is performance.
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Giorgi Moniava wrote: I did not say that...
It sure appears like you might have here.
In any case, the only way to know for sure is to try each method that you have a question about and measure it. In about as much time as it takes to post to this thread, you should have your answer.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: In about as much time as it takes to post to this thread, you should have your answer.
Yep , you are right it took me really long to post this thread , now I regret that I posted
DavidCrow wrote: In any case, the only way to know for sure is to try each method
I'll do this
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Giorgi Moniava wrote: now I regret that I posted
you regret it ???
i'm wonder why i'm still helping this forum...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: i'm wonder why i'm still helping this forum...
come on tox , you know this forum needs you
I meant that I should first try out all variants and then if did not get any results post the question , but I did it on the contrary.
That was what I regretted.
But thanks for your reply as I told you I will try what you suggested first.
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
ah, now you said it
have a good luck with that project sir.
ps: i may be interrested in it... is there any way to end it as an article ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: ps: i may be interrested in it... is there any way to end it as an article ?
Yes there is , and maybe I will write down a fully implemented class for that with many methods and operator overloading and so on.
Tomorrow I am going to buy the book of D.Knuth so I hope to find there algorithms of implementing the arithmetic operations with high performance.
Because what I wrote till now were simple algorithms which came to my mind , but they were not bad
Anyway you will be first to know , if I write down this class.
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Giorgi Moniava wrote: now I regret that I posted
Why ? you got good and polite answers ( IMHO )
Imagine that in fact there was a performance gain by using friends or static member functions, we all would have learned sometihng new today.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote: Imagine that in fact there was a performance gain by using friends or static member functions, we all would have learned sometihng new today.
Maybe you are right , but it is my fault also I could not formulate my question well.I knew what inline functions were for and knew that static and friend methods were not invented for increasing the performance , but I was interested which variant would be the best in this case.
I more expected such answer that "friend or static functions decrease the performance rather than simple class member or inline methods" or smth like that , so I would not use them.
Because using friend functions the user interface of the class was easy to use but if it decreased my performance then i would not use it.
So as I said maybe I should first have tried and then posted
Anyway thanks for your replies Maximilien
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 13:26 Wednesday 2nd November, 2005
|
|
|
|
|
Giorgi Moniava wrote: 1) CString add(CString &a,CString &b)
2) CString sub(CString &a,CString &b)
3) CString mul(String &a,CString &b)
4) CString div(CString &a,CString &b)
Since you are not changing the value of a or b , add the const keyword.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I'm sorry to diverge from your original question a bit, but I think you may be getting caught in a bit of an optimization trap. If you are worried about performace, I would address your use of strings for mathematical calculations long before worrying about whether a static, inline, friend, or global function is faster. I can't say I have ever seen a bignum library work with strings in the way you have shown. Each takes a string representation of a number, converts it to binary form, and uses that binary form for calculations. For examples, see the MIRACL[^] and Crypto++[^] libraries. If you need help with algorithms for bignum arithmetic, check out Knuth's Seminumerical Algorithms[^]
|
|
|
|
|
Kythen wrote: see the MIRACL[^] and Crypto++[^] libraries
that's quite good... but - just a guess - do you know any floating point libraries that can accept numbers bigger than a long double can ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Have you tried the DECIMAL data type?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Have you tried the DECIMAL data type?
nop, not yet, but thanks for pointing it...
i'll test it
thx
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
The only one I know of personally is the GNU MP Bignum Library[^]. It has arbitrary-precision floating point arithmetic capability thanks to the MPFR library[^]. I haven't used either one myself, but if you're interested in the algorithms behind it I believe the Knuth book discusses some and the MPFR page has some links.
|
|
|
|
|
I need to add a bitmap to menu item, so I've done this but it doesnt work:
CMenu Menu;
Menu.LoadMenu(IDR_MAINFRAME);
DWORD size = GetMenuCheckMarkDimensions();
WORD width = LOWORD(size);
WORD high = HIWORD(size);
CBitmap Bmp;
Bmp.LoadBitmap(IDB_BITMAP_NEW_P);
Menu.SetMenuItemBitmaps(ID_NEW_PROJECT,MF_BYCOMMAND, &Bmp, &Bmp );
Help anyone?
THANKS
Josip
|
|
|
|
|
|
Hi.
Is it possible to load a font directly from a font-file (*.ttf etc in an ordinary path) without registring the file in the system font tables (registry etc)?
thanks for the help, and good luck for your own projects
|
|
|
|
|
|
Thanks Chris
but see
-Font files must be in the SYSTEM subdirectory of the WINDOWS directory to be used by the AddFontResource function.
-The CreateScalableFontResource function is used to install TrueType fonts
-The EnumFontFamiliesEx function enumerates all fonts in the system that match the font characteristics..
I want to load a Font directly for a *.ttf or *.fon file. This file can be everywhere ( CD..)
Never the less thank you very much for trying to help me
|
|
|
|
|
AskQuestion wrote: -Font files must be in the SYSTEM subdirectory of the WINDOWS directory to be used by the AddFontResource function.
So just copy the .fon or .ttf file(s) to the Fonts folder before calling AddFontResource() .
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
thx Chris
it took a while to understand, since the help in msn isn't correct. AddFontResource.. really worked.
thx again, you really have been a great help
|
|
|
|