Stripping digits from an int

I have an RTC hooked up to my Arduino, which provides the year in 4 digits (ie 2013). To fit everything I need onto my Nokia 5110 display, I need to strip it down to an int that is only two digits long (ie 13).

I don't know if it's the extreme heatwave were getting in the South of England thats frying my brain, but surely this can be done easily? Perhaps I'm not thinking straight!

Modulo 2000 (it isn't that hot)

AWOL:
Modulo 2000 (it isn't that hot)

:smiley: Thanks for your help!

AWOL:
Modulo 2000

Wouldn't Modulo 100 make more sense?

2000 will get you an instant result (1 run).
100 would take 20 runs, if that is the way it actually works (i don't know).
2000 will last the next 87 years.
100 will last forever.

MAS3:
100 would take 20 runs, if that is the way it actually works (i don't know).

I think you have misunderstood how the modulo operator works.

@MAS3 ?
Modulo (operator %) ==> Calculates the remainder

2013 % 100 => 13
2013 % 2000 => 13
7 % 2 => 1

Last time I looked at an RTC it returned a string NOT an int (the op is make the normal beginners mistake).

Mark

holmes4:
Last time I looked at an RTC it returned a string NOT an int (the op is make the normal beginners mistake).

If that is the case it is very simple:

char year[5] = "2013";
char* digits = year+2;

digits now points to the string "13"

Last time I looked, the RTC I was using at the time returned neither "int" nor C string, but BCD digits.
The library attached to it returned an "int" though.
But then, it has been a while.

Will the OP provide a link to his RTC?

Mark