|
I want to know how can i assign infinity to a variable?
|
|
|
|
|
infinity is not a number, so you can't!
you can just use very big values using custom libraries for very big numbers.
Don't try it, just do it!
|
|
|
|
|
Since infinity doesn't exist (i.e., there's always one more number after the biggest number you can think of), how can you assign it to a variable? You can, however, assign a maximum value to integral types like:
int i = INT_MAX;
char c = CHAR_MAX;
unsigned long ul = ULONG_MAX;
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
It's easy, just use the infinity symbol. If you can't find it, take your keyboard back and demand a replacement.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Brilliant!!
Don't try it, just do it!
|
|
|
|
|
Where is the any key?
INTP
|
|
|
|
|
It depends.
If you value is a float or double , then it may be possible, take a look at:
numeric_limits<float>::infinity()
If your variable is an int, long or anything like that, then it is NOT possible to do - no matter what you set the value to, you can add to it and change it. (Although if it goes beyond the maximum value it can hold it will wrap around to a really big negative number!)
Now, if you want to know how to create an infinite loop, I've done that many times before...
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
Navin wrote:
if you want to know how to create an infinite loop, I've done that many times before...
Maxwell Chen
|
|
|
|
|
Wouldn't assigning infinity to a number require an infinite amount of time? If you every figure it out, I'll be glad to test for a small hourly wage
The maximum characters for the signature is five hundred. I was wondering how long a five hundred characters message would be, so I decided to make my signature 500 characters long. I'm sure if I had some cool html stuff in my signature, I could eat up five hundred characters, but just typing five hundred characters takes quite some time. The trick I think is finding something to say, but I'm usually a man of few words. So I guess I'll tell you what I've discovered is the secret to life. It
|
|
|
|
|
These functions are driving me nuts. They work about 90% of the time, then fail unexpectedly the other 10% (especially on Windows 98.) In particular GetExpandedName often seems to bomb, and there is no extended error information.
So are there any alternatives or other implementations? I need to be able to expand files compressed with the "compress" utility (typcially, the ones named something like "somefile.ex_")
Thanks.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
These files are compressed in a CAB file.
So two easy ways:
Take a custom CAB lib or call the compress command to decompress them
Don't try it, just do it!
|
|
|
|
|
Well, you have to call "expand" to uncompress them, but that won't work for my situation - many systems don't come with expand.exe (98 systems in particular), so we'd have to distribute it, and not sure if there are any strange licensing agreements.
Custom CAB lib? Tell me where to find it, that's what I'm looking for.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
|
Hello All,
Can anyone tell me that what is the different when declare function like
const char* f();
and
char* const f();
I would like to know what does this two function signature means.
Thanks!
Nachi
|
|
|
|
|
easy, the second don't exist ! lol
in fact, you might want to say
const char* f();
char* f const();
that's simple. the first one returns a const char* when the second one returns a simple char*.
What does the second const mean, you'll ask me !? In fact, that is used in object programming, when you read values in an object, where you don't alterate that object... In brief, it means that you don't modify the members of your objet... you don't need this in pure C so...
see you
TOXCCT >>> GEII power
|
|
|
|
|
Ummm,
You said the second one
char* const f();
does not exist, but if I write this in Visual C++, the compiler does not complain. Also, for the first one, I can actualy return something which is not a const, eg,
const int f()
{
int i = 10;
return i;
}
and it also works in Visual C++ too. And would you mind to tell me why's that?
Thank you very much!
Nachi
|
|
|
|
|
Stop playing silly games in here, returning a const value doesn't make any sense!
Don't try it, just do it!
|
|
|
|
|
Hello,
You are right, I know that it does not make any sense, but I still don't know what is this,
int const f();
even thought I never use it in my programming experience. But in some C++ test, people ask something about this, and what I know and what I have used is only something like this,
void f(const int);
or
void f(int) const;
and these both make sense to me, but not
int const f();
therefore, the's why I would like to know whether this signature make sense to any of you.
But anyway, thank you for all your suggestio!
Nachi
|
|
|
|
|
Did this not help?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Sorry, it doesn't really help, I know how to use a constant data in a program, but I have some confussion when using in the definition of functions
Thanks!
Nachi
|
|
|
|
|
So doesn't it make more sense to continue that thread rather than creating a new one of the same topic?
In any case, MSDN has this to say about const :
When modifying a data declaration, the const keyword specifies that the object or variable is not modifiable. When following a member function's parameter list, the const keyword specifies that the function doesn't modify the object for which it is invoked.
With C++, const is often used in place of the #define preprocessor directive. Values defined with const are subject to type checking, and can be used in place of constant expressions.
When const is used with pointers, it specifies that the pointer cannot be modified after initialization; the pointer is protected from modification thereafter.
So, const char *cpch means that the object pointed to by the pointer is const. And, char *const pchc means that the value of the pointer — the actual address stored in the pointer — is const.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
const char* means "pointer to a constant char " - you cannot change the value of the char that is pointed to, but you can change the pointer to point at some other char .
char* const means "constant pointer to a char " - you can change the value of the char pointed to, but you cannot change the pointer to point a some other char .
And const char* const means a combination of the two.
Example code:
char c = 'c';
char d = 'd';
const char* p1 = &c;
char* const p2 = &c;
*p1 = 'x';
p1 = &d;
*p2 = 'z';
p2 = &d;
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Laugh it up, fuzzball.
|
|
|
|
|
I've used the sample code from the posting about 'using alxBase classes with dbf files' and I can't get the table to be recognized by foxpro. does anyone have any knowledge of how to use an api to create a foxpro (or dbase) table through code and specify the correct header info. Following is what I wrote to the author of the code, but just in case, I'm looking for some help as quickly as possible.
this is my fault. I don't understand how to modify the header info correctly to specify the table type correctly (along with the other fields). I create a table, and using the sample viewer demo that came with this project, I can see the data in the table, even though a couple of the column header names are messed up. But when I try to open up the table in VFP I get a message telling me to specify the code page it was created in. I tried to modify the header info, but I can't seem to get this to work right. Can you please help?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
I'm silly guy , I've just changed the system language and it works.
In that way, all the controls can show text in russian.
.... I'm furious!.
Bye.
Demian.
|
|
|
|
|
Is it possible to have a class instantiate a second class in it's constructor by passing a "this" pointer to the second class? And then have the second class hold and use the pointer to the first class? I believe this is causing a circular dependency and I don't know how to get around it. In other words, class A includes a header file for class B. Class A then instantiates a new class B in its constructor like this: B* classB = new B(this). Class B then needs to include the header file for class A so that it can hold a pointer to it and call functions on it via this pointer. I've tried using forward declarations, but I get an error saying that class so-and-so is undefined. Is there any way to do this or do I need to rethink my code?
|
|
|
|