6 Replies - 14316 Views - Last Post: 27 August 2009 - 08:21 AM Rate Topic: -----

#1 izzahaf   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • 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

what it mean about? please help me.

thanks before.

Is This A Good Question/Topic? 0
  • +

Replies To: A value of an integral type expected

#2 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#3 izzahaf   User is offline

  • D.I.C Head

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

Re: A value of an integral type expected

Posted 26 August 2009 - 09:27 AM

View PostPsychoCoder, 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.
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • 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]):
Was This Post Helpful? 1
  • +
  • -

#5 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • 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

Was This Post Helpful? 1
  • +
  • -

#6 izzahaf   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#7 cipi20052000   User is offline

  • New D.I.C Head

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

Re: A value of an integral type expected

Posted 27 August 2009 - 08:21 AM

View Postizzahaf, 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1