#### Archived

This topic is now archived and is closed to further replies.

# symbolization

## Recommended Posts

how do i make something symbolize like 1 through 90 i cant us 1 -> 90? or 1-90. so what can i do?

##### Share on other sites
quote:
so what can i do?

##### Share on other sites
for example

int a = all numbers 1 through 90

##### Share on other sites
use a for loop:

  for(int i = 0;i <= 90; i++)

##### Share on other sites
I think he means an abstract number.
Where x=1 would be True, as would x=90 and everything in between.

-[Image Sig removed by Run pending staff/mod consultation]
-ryan@lecherousjester.com

##### Share on other sites
>>I think he means an abstract number.
Where x=1 would be True, as would x=90 and everything in between.

EXACTLY !!!

##### Share on other sites
You would need a class and some overloaded operators, I think. Try to find a way around it for now.

If you really need an int to be several different numbers at once, you could try building a quantum computer.

##### Share on other sites

  if (x>0 && x<91){// do your stuff}

Is this what you look for??
What language do you use??

c++ and no

##### Share on other sites
this is what i need but wont work

int y2;
y2>0 && y2<91;

##### Share on other sites
if( y2>0 && y2<91 )
{
//This code is run if y2 is between the numbers
}

did you do this?

##### Share on other sites
AFAIK, a var can''t store anything but one value at a time...
You don''t want it to be a random value in a specific range, do you??

##### Share on other sites
yes thats what i want, a=all numbers 1 to 90

##### Share on other sites
If you can think of a way to use such a variable that can''t be done better and simpler in another way, I''ll give you a cookie. What you''re asking can''t be done simply. Try to re-think your problem.

##### Share on other sites
Why exactly do you want to do this? There is probably a far better method for what you need.

And, as someone else mentioned, it probably wouldn''t be that difficult to create a class with that behavior, although I can''t imagine what you would need it for.

##### Share on other sites

    class RangeNumber{  public:    RangeNumber(int low, int high)    {      if(low > high)        throw "Error! Low bound must not be greater than high bound!";      this->low = low;      this->high = high;    }    bool operator==(int n)    {      return (n >= low && n <= high);    }  private:    int low;    int high;};

Something like that ...

[edited by - Miserable on December 23, 2002 5:58:11 PM]

##### Share on other sites
quote:
yes thats what i want, a=all numbers 1 to 90

If you want it to be one random number out of 1-90, you can do rand()%91

But I don''t think this is what you want to...

##### Share on other sites
What a useless class. I think it needs a = operator, and then it should be exactly what craphead wanted.

EDIT: Wait, never mind. A = operator would also be useless.

[edited by - micepick on December 23, 2002 6:04:27 PM]

##### Share on other sites
quote:
Original post by micepick
What a useless class. I think it needs a = operator, and then it should be exactly what craphead wanted.

I never claimed it''s useful - it''s not, but I think it''s something like what the OP wanted.

How would you write an operator=()? I don''t know how it could be made to take more than one parameter.

##### Share on other sites
All these post and no one has mentioned an array? And this is the beginner forum and you guys are talking about a class with overloaded operators? Shame on you all.

int a[90],j;for(j=0;j<90;j++) a[j]=i+1;// you can loop thru and access all// the elements like this:for(j=0;j<90;j++)  printf("\n %d",a[j]);

[edited by - nonnus29 on December 23, 2002 9:53:41 PM]

##### Share on other sites
Well, that doesn''t seem at all like what he was asking for. Or is it just me?

##### Share on other sites
quote:
this is what i need but wont work

int y2;
y2>0 && y2<91;

Did you write it as ''if(y2>0 && y2<91);'' instead of ''if(y2>0 && y2<91)'', because that would make the if statement always appear to work, even if it shouldn''t.

##### Share on other sites
You don''t understand. He''s asking for an object that is all the values between 1 and 90:

  range_int x;x>0 && x<91;  <---- bizarre syntaxif (x==5){  // this code executes}if (x==30){  // this code also executes}

At least, that''s the impression I got.

##### Share on other sites
perhaps if we knew what the hell he wanted it for we could think of a solution...

##### Share on other sites
Can you even imagine how USEFUL this would be for collision detection? :-D

ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!

• ### Forum Statistics

• Total Topics
628391
• Total Posts
2982419

• 10
• 9
• 19
• 24
• 11