BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Ah, integer math is hard, even for Google!

Needing a new car battery, I was trying to see if Google knows how many years is a 84 month warranty (Yes, I can do it in my head of course!).

 

Apparently, google gives almost the correct answer, but the result is about 5 minute off. 😄

 

Bonus question: What possible numerical representation do they use to be off this way?

 

altenbach_0-1677265255715.png

 

Message 1 of 7
(3,712 Views)

Google's just accounting for leap years 🙃

Matt J | National Instruments | CLA
Message 2 of 7
(3,683 Views)

@Jacobson-ni wrote:

Google's just accounting for leap years 🙃


That was actually my first thought, but 5 minutes over 7 years is much, much less than a day. 😄

 

(... maybe its an intentional trap to see if somebody steals their code, similar to the use of trap streets on maps.)

0 Kudos
Message 3 of 7
(3,673 Views)

Leap year is every 4 years, but every 100 years that is skipped, and every 1000 years the skip is skipped 😄

 

So the the question would be: Do they use the Sidereal, tropical, and anomalistic year?

 

And there are even some more ...

https://en.wikipedia.org/wiki/Year#Astronomical_years

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 4 of 7
(3,519 Views)

Leap seconds (Wikipedia)?

 

IIRC, there can be 59 to 62 seconds in a minute, although 62 is rare.

 

This is probably just rounding, although a sgl, dbl (nor ext, sigh) get us this rounding error.

 

I have run into these kind of problems. I developed an integer math library at some point, to support math on integer fractions. Pretty straight forward, but it does solve problems in a few (very specific) situations.

0 Kudos
Message 5 of 7
(3,514 Views)

Well, I understand the potential issue with the division, but the second problem is just a multiplication, they even give the formula (multiply the value by 12).

 

7 x 12 is NOT 83.9999, even in SGL or U8.

 

I don't think leap seconds/years matter because it does not add up.

 

Once we go to fractional years in units of months, there is entire new can of worms, because each month has a different number of days.

 

0 Kudos
Message 6 of 7
(3,495 Views)

Curiously, of we ask in a slightly different way, we get yet another result.

 

Apparently, a year has now approximately 12.008 months. (Maybe we should tell Gregory!)

 

 

altenbach_0-1677518928909.png

 

Now. I wonder if they already made some changes based on me clicking on the feedback button 😄 .

Actually, it depends if we pick "year" or "calendar year" as unit. Now I need to look up the definitions.... 😮

 

(This seems about right when considering leap years, but it is an approximation. For example there could be 1 or two leap years in that interval, depending on the start)

 

0 Kudos
Message 7 of 7
(3,492 Views)