float to hex?

Probably stupid, but i calculate some float value with a result 0.0 to 255.0 . I have to set a timer counter value at :

  REG_TC4_COUNT8_CC0 = 0x55; //or other value

How would I convert

float CC=137.0

into a hex value (to replace the 0x55 in the timer counter as other possible value) ?

Thanks.

byte myVar = CC;

But why did you use a float in the first place then?

Btw, it's not a conversion to hex (which is only a representation of a number) but a conversion to integer.

Not sure if this is what you want, but all numbers are ultimately stored in binary, so picking one over another is just its representation:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  float CC = 137.0;
  int val;
  val = (int) CC;
  Serial.print("val = ");
  Serial.println(val, HEX);
}

void loop() {

}