# A value of an integral type expected

Page 1 of 1

## 6 Replies - 14316 Views - Last Post: 27 August 2009 - 08:21 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=122348&amp;s=e0901c56e59798555eddc79db906682d&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 izzahaf

Reputation: 1
• Posts: 112
• Joined: 12-March 09

# A value of an integral type expected

Posted 26 August 2009 - 09:18 AM

i'm sorry, i need help again.

i have a switch case condition
```switch (this.tHit[i][j])
{
case (tHit[i][j]>=kappa-this.bestBias[0][j]):
this.gHit[i][j] = 1;
case (tHit[i][j] <= kappa - this.bestBias[0][j] && this.tHit[i][j] >= -this.bestBias[0][j]):
this.gHit[i][j] = (beta1 * this.bestBias[0][j] + Math.Pow(beta2 * this.bestBias[0][j], 2)) + (beta1 + 2 * beta2 * this.bestBias[0][j]) * tHit[i][j] + beta2 * Math.Pow(tHit[i][j], 2);
case (this.tHit[i][j] <= -this.bestBias[0][j] && tHit[i][j] >= -kappa - this.bestBias[0][j]):
this.gHit[i][j] = (beta1 * this.bestBias[0][j] - Math.Pow(beta2 * this.bestBias[0][j], 2)) + (beta1 - 2 * beta2 * this.bestBias[0][j]) * tHit[i][j] - beta2 * Math.Pow(tHit[i][j], 2);
case (this.tHit[i][j]<=-kappa-this.bestBias[0][j]):
this.gHit[i][j] = -1;
}

```

and i got an error in switch(...) : Error 1 A value of an integral type expected

thanks before.

Is This A Good Question/Topic? 0

## Replies To: A value of an integral type expected

### #2 PsychoCoder

Reputation: 1659
• Posts: 19,853
• Joined: 26-July 07

## Re: A value of an integral type expected

Posted 26 August 2009 - 09:24 AM

That means that the type used in the switch() statement is required to be an "integral" type. As in "integer". As in NOT "array of integers".

The switch() statement simply does not work with complex types. Anything that can be represented as a simple integer value is fine. Anything else is pretty much not, with the exception of strings.

### #3 izzahaf

Reputation: 1
• Posts: 112
• Joined: 12-March 09

## Re: A value of an integral type expected

Posted 26 August 2009 - 09:27 AM

PsychoCoder, on 26 Aug, 2009 - 08:24 AM, said:

That means that the type used in the switch() statement is required to be an "integral" type. As in "integer". As in NOT "array of integers".

The switch() statement simply does not work with complex types. Anything that can be represented as a simple integer value is fine. Anything else is pretty much not, with the exception of strings.

the condition in my switch is in double Psycho, is it not work?

thanks.

### #4 PsychoCoder

Reputation: 1659
• Posts: 19,853
• Joined: 26-July 07

## Re: A value of an integral type expected

Posted 26 August 2009 - 09:30 AM

No, a switch statement cannot work with complex types such as arrays and such. Put it in an if..elseif statement. It also will not work with evaluation statements such as case (tHit[i][j]>=kappa-this.bestBias[0][j]):

### #5 SixOfEleven

• Planeswalker

Reputation: 1055
• Posts: 6,643
• Joined: 18-October 08

## Re: A value of an integral type expected

Posted 26 August 2009 - 09:33 AM

Of what type is tHit? An integral types are types like int, long, char, byte. Other types like float, double can not be used in switch statements.

*edit*
Stepped a way from the computer for a few minutes before finishing my answer.

This post has been edited by SixOfEleven: 26 August 2009 - 09:34 AM

### #6 izzahaf

Reputation: 1
• Posts: 112
• Joined: 12-March 09

## Re: A value of an integral type expected

Posted 26 August 2009 - 09:46 AM

thanks psycho & six, i use if else condition.

### #7 cipi20052000

Reputation: 1
• Posts: 25
• Joined: 26-August 09

## Re: A value of an integral type expected

Posted 27 August 2009 - 08:21 AM

izzahaf, on 26 Aug, 2009 - 08:46 AM, said:

thanks psycho & six, i use if else condition.

I think that your problem is not necessary on the switch line. I thing the case is the problem. When you use case statement you expect a variable to take a value. You can't make comparison with "case". I'm not sure about the switch line, but where you used "case", there's certain a problem. Psycho, if you by mistake read my reply please tell me your opinion. Thanks

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }