UNO / EVERY problem with converting variables?

Why is this sketch running correct on the UNO and not on the NANO EVERY?

Can anyone help me please.

Welcome to the forum

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

Please post your full sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

It is also helpful to post full error messages in code tags as it makes it easier to scroll through them and copy them for examination

To post the error message, click the "COPY ERROR MESSAGES" button in the IDE, paste the copied messages in a reply here, select all of it and click the < CODE > icon above the reply editor to add the code tags and then save the reply

The Nano Every uses a different microcontroller (ATmega4809) than the UNO (ATmega328P). Differences in memory, I/O registers, and default variable sizes can cause sketches that run on the UNO to fail or behave differently on the Nano Every. Check variable types, pin definitions, and libraries—update them for compatibility with the ATmega4809.

A clue lurks in the fact that

40000 + 25536 = 2^32

a7

See this discussion https://forum.arduino.cc/t/function-abs-on-every-malfunctioning/1150330

Different implementation for abs(), you need to use labs() for long.

Please post your code using code tags <CODE/>

Please, no images or screen shots of code