The meaning of (int)

Thank you.

I am trying to turn on LED D13 using <TimeLord.h>.
However, since the data type is a byte array type, I am looking for a way to convert it to an int.
It looks like you can take a serial value and change it to int type, but in the code below, “Serial.print((int) today[tl_hour]);” I don’t understand the part.

Question 1) What does the (int) part mean in particular?

Question 2) Is there a way to convert byte type array to int type integer in Arduino?

if (tardis.SunRise(today)) // if the sun will rise today (it might not, in the [ant]arctic)
  { 
    Serial.print("Sunrise: ");
    Serial.print((int) today[tl_hour]);
    Serial.print(":");
    Serial.println((int) today[tl_minute]);
  }
  

You can learn about it here (note there are two different syntax styles for type casts):
https://www.arduino.cc/reference/en/language/variables/conversion/intcast/

1 Like

Thank you.
Good luck to you. :joy:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.