JChristensen / DS3232RTC

Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks
GNU General Public License v3.0
392 stars 135 forks source link

Why temperature times 4? #47

Closed emilydohrem1111 closed 6 years ago

emilydohrem1111 commented 6 years ago

According to the documentation, the temperature() function returns the temperature times four. Why is this the case? Won't it be better to just return the temperature directly? I may be missing something here.

Documentation:

Returns

RTC temperature as degrees Celsius times four. *(int)*
JChristensen commented 6 years ago

I wanted to keep the code size small. Returning temperature in degrees as an integer loses precision. Returning floating point incurs processing overhead as well as larger code size. By just returning the raw data from the RTC register, the caller can handle it however they want.