|
as Jack Squirrel said, you can do this in the calculator of your choice :
2^32 -> 4294967296 (maz value of an unsigned long)
131221*229123 -> 30065749183 (out of range...)
if you like to use an integer absolutely, use __int64. otherwize, double or long double are good enough...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
131221*229123 = 30065749183 but you get 978111.
Basically your number is truncated. Look at the hex representation.
30065749183 = 0x7000EECBF
978111 = 0x0000EECBF
Use __int64.
|
|
|
|
|
Does anyone have any suggestion on what software I should purchase to start programming in C. I am a beginner. Found that I love to write code and create things. any suggestions would be helpful. Thanks
|
|
|
|
|
Are you hoping to use C, C++ or C# ? C is a bit outdated these days, and would certainly have a steep learning curve. The C++ curve is not insurmountable, but C# would be easier. There are free options for all of these languages, but if you can get your hands on a copy of Visual Studio, for example if you're a student and can buy one at the educational price, it would be well worth your while. The help a good IDE gives you makes learning a whole lot easier. I shudder when I think of the terrible IDE's I used when I was learning, because I got them cheap ( not to imply that Microsoft are the only people to do a good IDE, but VS is excellent, the price is right if you can get education pricing, and it means you have a number of languages at your disposal out of the box ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
You can download VS 2005 beta. It's free, and a very good tool for programming in C, C++ and C# (if you want to program in these languages).
I also got the blogging virus..[^]
|
|
|
|
|
it looks like C# is the way to go by both replies. I'll have to check on prices. I'm hoping it won't be to bad.
Thank you for the help.
|
|
|
|
|
Any body knows how to find out if the harddrive is fragmented via C++ or WMI script?
thanks in advanced.
|
|
|
|
|
|
Hi
I have a project that is dependent on some of the laiter windows platforms for some of it's functionallity so the question is is there a way of determinig the OS running.
and
how many different windows platforms are there.
can anyone help me.
G_S
|
|
|
|
|
G_S wrote:
how many different windows platforms are there.
Lots.
I'm serious - if you factor in all the various versions of IE, the service packs, the Win9x and WinNT lines, it's a frighteningly large number.
Generally, if you wish to use an API that only exists in certain versions, you're best finding a way to include the redistributable for that API along with your install. Failing that, test for the existence of the API prior to using it (for regular APIs, that usually means LoadLibrary() + GetProcAddress() rather than static linking).
For other platform-dependant functionality (such as registry locations, file formats), you're gonna have to either get more creative, or write for the lowest common denominator.
You must be careful in the forest
Broken glass and rusty nails
If you're to bring back something for us
I have bullets for sale...
|
|
|
|
|
Thanx
It's Actually only the API and specifically the tool help functions.
I was really hopping for something nicer to read.
so this leaves me with no way around the LoadLibrary ,GetProcAddress ..
Thank you anyway
G_S
|
|
|
|
|
G_S wrote:
is there a way of determinig the OS running.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/osversioninfo_str.asp[^]
But like Shog said, if you use unsupported API's, then you need to dynamically load them, or your app won't run, even if you never run the code that calls them. The alternative is to write your own versions. I did that with TransparentBlt and AlphaBlend many years ago, so I could support W95 and still call them.
G_S wrote:
how many different windows platforms are there.
Assuming you start with W95, there's W95, W98, NT4, WME, W2000, WXP. Then W98 has service pack 2 to consider, that added a lot, from memory.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you for the link.
So the best work around the dependencies is to dynamically load and test for the functins.
Thanks for the anwser this helps.
G_S
|
|
|
|
|
No, the best way is to use the link I gave you to find out what OS you have, then to dynamically load the functions and only allow the code to use them based on the results of that test, which will have told you if they are present, based on OS version. There's only one test involved, the dynamic loading is because otherwise Windows will try to load the functions, even if they don't exist, regardless of the fact that your code deals with that problem for you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I use this code snippet
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Hiya
I have a variable that shoud return a value of say... 50. Instead it's returning 49.9999999956 which may sound pretty good but I need the 50. I found this thing in the Std library which is an enum called float_round_style that includes something called round_toward_infinity ... but I can't find how to actually use the durn code, an example or anything other than the description . Can anyone tell me how to use it? Is there any other easier way to acomplish what I want?
Thanks!!!
|
|
|
|
|
double d = 49.9999999956;
int i = (int)d;
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Nope, that leaves me with 49, not 50.
|
|
|
|
|
I find that very difficult to comprehend. Numbers should round up from .5 upwards, thought. That makes the floor function totally useless.
This will work.
#include<math.h>
double d = 49.99999956;
int i = (int)ceil(d);
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you! that sure works!!!
|
|
|
|
|
The Function "double ceil(double);" will always round UP.
that is even if you have 49.00005 the ceil() function will round UP to 50;
if you want to round to the nearest Integer
you need somthing else.
G_S
|
|
|
|
|
G_S wrote:
The Function "double ceil(double);" will always round UP.
I guess that's why it's called ceil ( as in ceiling ).
G_S wrote:
if you want to round to the nearest Integer
you need somthing else.
I was helping someone who wants to round UP. However, casting to int seems to just drop the floating point part, when I assumed it would round to the nearest int, up or down. HEnce, I suggested ceil.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
To alter the processor's default rounding behavior, you can use the _controlfp() function to set specific FPU flags (such as _RC_CHOP , _RC_UP , _RC_DOWN , _RC_NEAR ).
You must be careful in the forest
Broken glass and rusty nails
If you're to bring back something for us
I have bullets for sale...
|
|
|
|
|
Hello,
The standard implies that when a floating point value is converted to a intergral value, the fractional part is discarded...
I also got the blogging virus..[^]
|
|
|
|
|
ceil()
You must be careful in the forest
Broken glass and rusty nails
If you're to bring back something for us
I have bullets for sale...
|
|
|
|