unsigned long match question

I have this statement:

Xpos = Xpos * 19230UL;

The number 19230 -- I'd like to set it as a constant or #define in the beginning of my sketch, since it's used a few places, and I may change it later. But I need the unsigned long math to work properly. Will this work, or do I need to add UL in there somewhere with myVal? Thanks.

const unsigned long myVal = 19230;

Xpos = Xpos * myVal;

is Xpos an unsigned long as well? in that case all will be fine.

yes, Xpos is an unsigned long. So it'll be fine then. Thanks.

for peace of mind and being very clear I would write

const unsigned long myVal = 19230ul;

but it does not change anything, just better readability.

it would not work though if later you need that value to be 100 times larger and you writeconst unsigned long myVal = 19230 * 100; // integer overflow !!! --> that's where the UL would become really importantconst unsigned long myVal = 19230ul * 100; // No overflow !!!

you could also do #define myVal 19230ul (but as you rightly used const the compiler will likely optimize all this and I like it better that way)