I have a very simple equation which works fine from 0 to 65 (MPH in this case), but when it goes above this speed, it shows 1,2,3 MPH... Somehow my variable is overloading and looping back to 0 again.. has anyone seen this before?

I pick up data from an array - equating to speed in Knots:

SSD4= (ssmax[18]>>4)
SSD3= (ssmax[18] & $f)
SSD2= (ssmax[17]>>4)
SSD1= (ssmax[17] & $f)

Then convert to Decimal:
Dec_speed=(ssd4*4096)+(ssd3*256)+(ssd2*16)+ssd1 ' convert to dec

Then convert to MPH:
Dec_speed = (Dec_speed*115)/100

Then display it:

LCDout $fe, L4, " Speed:",#Dec_speed dig 3, #Dec_speed dig 2,#Dec_speed dig 1, ".",dec1 Dec_speed

What I see works great until 65mph, and then it starts over at zero again.. at 10mph I am actually going 75mph...

The Dec_Speed variable is a word..

Looking at the values for KNOTS that I get in the data, it is an 'implied' decimal, so the speed calculation looks like the following going from (520) 52.0 knots to (572) 57.2 knots... As you can see at 57.0 knots the equation is generating a value greater than 65,536.. thus it is wrapping...

Question is WHAT does one do about this?

Knots MPH
520 59800 59.8
521 59915 59.915
522 60030 60.03
523 60145 60.145
524 60260 60.26
525 60375 60.375
526 60490 60.49
527 60605 60.605
528 60720 60.72
529 60835 60.835
530 60950 60.95
531 61065 61.065
532 61180 61.18
533 61295 61.295
534 61410 61.41
535 61525 61.525
536 61640 61.64
537 61755 61.755
538 61870 61.87
539 61985 61.985
540 62100 62.1
541 62215 62.215
542 62330 62.33
543 62445 62.445
544 62560 62.56
545 62675 62.675
546 62790 62.79
547 62905 62.905
548 63020 63.02
549 63135 63.135
550 63250 63.25
551 63365 63.365
552 63480 63.48
553 63595 63.595
554 63710 63.71
555 63825 63.825
556 63940 63.94
557 64055 64.055
558 64170 64.17
559 64285 64.285
560 64400 64.4
561 64515 64.515
562 64630 64.63
563 64745 64.745
564 64860 64.86
565 64975 64.975
566 65090 65.09
567 65205 65.205
568 65320 65.32
569 65435 65.435
570 65550 65.55
571 65665 65.665
572 65780 65.78


TG