16,007,277 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Shvetsov Evgeniy (Top 21 by date)
Shvetsov Evgeniy
17-Jun-16 10:06am
View
"ArrayItem[0] will be the low order part of the first 64-bit value, ArrayItem[1] will be the high order part" - on little-endian machines, i guess. The problem is, as i now know it, reading values using uint32_t* pointer, converted from original uint64_t* pointer - is undefined behaivour, due to the CPP standart. So it can be just garbage or this code can evenly be optimized out by the compiler. I hope it is NOT, as i'm using such a code already, but can't be sure, espically for other platforms. I really love C++ but some thimes i just hate it. And i blame myself for stupidity too.
Shvetsov Evgeniy
16-Jun-16 8:21am
View
Thanks for your reply! Yes, to handle the resulted values correctly is the problem.
Shvetsov Evgeniy
16-Jun-16 8:20am
View
Ok, looks like i didn't formed the question correctly (precisely enough), living too much room for condsierations. But this is my own fault, while your answer is detailed, interesting and usefull, i would accept it. Thank you.
Shvetsov Evgeniy
10-Jun-16 19:26pm
View
Well, as we say in Russia: "the old mule ploughs a straight urrow" :) ANY programming language which continues to evolve is affected by this problem. The Java language, i think, is the most famous example here. The problem is you can NOT foresee all, so the problem is strictly human based AND so it is insoluble, as the mankind, in opposite to the technology, is NOT evolving (OR at least NOT so fast).
Shvetsov Evgeniy
10-Jun-16 17:06pm
View
Thanks for your reply! "There is no reason to remove volatility using const_cast" - if there were NO reason, i guess C++ standardization committee would NOT allow to do that. "If stars are lit it means - there is someone who needs it".
Shvetsov Evgeniy
10-Jun-16 17:01pm
View
Thanks for your answer! A kludge naturally built-in in the programming language is a very interesting phenomenon by itself :) Through C++ has more such a things: mutable AND friend, which breaks constness AND encapsulation.
Shvetsov Evgeniy
9-Jun-16 13:24pm
View
Of course the compiler is NOT executing MY code directly, because MY code is in the C++ language, which is human-readable, while the CPU executes the machine code AND this machine code is the result of MY human-readable C++ code being transfered by the compiler to the machine code, this is pretty obvious really :))
Shvetsov Evgeniy
9-Jun-16 9:25am
View
Thanks for your reply! Putting the code into an external library (you're talkig about the dynamic lib., of course) is the possible way, yes, thank you!
Shvetsov Evgeniy
9-Jun-16 9:23am
View
Thanks for your reply! Of course it is. Sorry, but this all is just meaningles, there are plenty of examples of such a things, calculating factroial in compile time, evaluating str. len. etc. There is just NO way to "evaluate" OR "calculate" something WITHOUT executing code.
Shvetsov Evgeniy
8-Jun-16 17:38pm
View
Thanks for your answer! Unfortunatly, it's not i was looking for, but anway still thank you!
1) This is lazy init, yes, there are plenty of ways how to implement singleton pattern (which is, in fact, applys the only restriction of one and single instance per any unit of execution time). The good example of how it can be done is shown in the wikipedia: https://en.wikipedia.org/wiki/Singleton_pattern#Example - there 5 (!) ways how to do that JAVA-way.
2) I understood what you're talking about, YES, we can set the instance private while proiding the public getter to access it, BUT there is just NO reson to do that when your singleton is a CONST. It's just meaningles in this case. Just minimalistic minimalistic way for implementation :)
Shvetsov Evgeniy
8-Jun-16 16:14pm
View
1) volatile is NOT a recommendation, ofcourse not, never be, never was. I'l reccomend you familiarize yourself with this qualifier, as you currently clearly misundersttod it. Here is a good article: http://www.drdobbs.com/parallel/volatile-vs-volatile/212701484
2) There is, of course, dynamic singleton, which is, opposite to static, allocated and created on demand in run time.
3) My singleton realization is a simple "out of the box" solution, if you can proof you can properly create many instances of it, then show me how! :)
Shvetsov Evgeniy
8-Jun-16 15:19pm
View
I'm sorry, but y're completly wrong here.
1) Here you can find an examples of how code runned compile time:
http://stackoverflow.com/questions/12108390/c11-compile-time-calculation-of-array
http://stackoverflow.com/questions/25890784/computing-length-of-a-c-string-at-compile-time-is-this-really-a-constexpr
2) The volatile keyword prevents optimization, as it tells the compiler to drop ANY assumptions which he maid among the volatile object, so free that object of optimizations.
"Basically, volatile announces that a value might change behind your program's back. That prevents compilers from caching the value (in a CPU register) and from optimizing away accesses to that value when they seem unnecessary from the POV of your program" - from http://stackoverflow.com/questions/3604569/what-kinds-of-optimizations-does-volatile-prevent-in-c
3) constexpr works diffrentley depending on what actually is marked "constexpr":
"constexpr function allows the function to be evaluated at compile time, but does not require that, so your answer is "maybe". It depends on the compiler's optimization settings. If you wish to have no runtime cost, you could force compile-time evaluation by assigning it to a constexpr variable" - from http://stackoverflow.com/questions/12785691/c-constexpr-at-compile-time?rq=1
Through we just completly reversed teacher/learner relationships here, stil thank you for your reply.
Shvetsov Evgeniy
21-Mar-16 17:10pm
View
"Why" what? 9/8 gives 1,125 while 4/5 gives 0,8 and 2/1 gives 2.0, do y see there some 'infinity'? 64 bit IEE754 floating point gives only up to 15–17 significant decimal digits precision, so 1/3 as a decimal fraction can't be longer then 17 digits (as a number) anyway. I am upgrading a convertion module form my library and i want it to be implemented in the efficient way, thats exactly what i want.
Shvetsov Evgeniy
17-Mar-16 12:58pm
View
But still, MS VS 2013, even fully updated (Community Update 5) miss that 'DBL_DECIMAL_DIG' constant, which isn't good. I guess that modern GCC or Intel compiler has no such problem.
Shvetsov Evgeniy
17-Mar-16 12:54pm
View
Yes, i know that MS VS didn't support long double, but i am developing a portable code, so it doesn't matters. Any way, your answer is very clear, informative and usefull, thanks a lot, you completely solve my problem.
Shvetsov Evgeniy
17-Mar-16 12:12pm
View
What the point of your meaningless comment and your negative vote?
The question is in the very first line and it is "MS VS 2013 'LDBL_DIG' const. From 'float.h' is incorrect?"
Shvetsov Evgeniy
23-Feb-16 20:39pm
View
I want exactly what you talking about, but the next time original value would be 1.12 and the 100000 would't work. This is the first problem. The seond problem is that you can mangle the value that way (see 'What I have tried').
So i need a way to somehow transform a double value to integer value fastly and loosing nothing. I am assuming there should be some CPU inrinstic or somewhat similar to do that. If humnaity launches rockets i hope there way to do this too :))
'There is heaps of methods to transform a fractional part to an integer' - OK, what is the efficient then? DO you know how to do that involving the constant operations count?
Shvetsov Evgeniy
23-Feb-16 19:55pm
View
Thx, but i already read those. The problem is that i need a fractional part NOT as a double (the standart 'modf' do this), i need it to be an integral number. Converting it to text and then back to number is too complicated. I looking for a much faster solution.
Shvetsov Evgeniy
23-Feb-16 19:39pm
View
It was 'convert fractional part of a double to int' until edited. 123.321 had 123 as an integral part and 0.321 as a fractional part. I need to get int = 321, as example shows. The precision of any type is finit, so i need to convert it to an unsigned long long int without lossing precision and regardless of the digit's count (constant complexity).
Shvetsov Evgeniy
23-Feb-16 19:33pm
View
Nope, the digits count is undetermined
Shvetsov Evgeniy
23-Feb-16 19:02pm
View
I added an example, but the question itself is pretty straight and clear already..
Show More