Adding Information about traps with the function maps

This is a programming error to use unsuitable types; The map function has nothing to do with it.

if I run

void setup()
{
  Serial.begin(115200);
  unsigned long rawToBeMapped = 1000000;
  unsigned int mappedValue;
  Serial.println(map(rawToBeMapped, 123, 255, 0, 1023));
  mappedValue = map(rawToBeMapped, 123, 255, 0, 1023);
  Serial.println(mappedValue);
}

void loop() {}

I get 7749046 and 15798 which seems right to me.

and if you print the hex values

void setup()
{
  Serial.begin(115200);Serial.println();
  unsigned long rawToBeMapped = 1000000;
  unsigned int mappedValue;
  Serial.println(map(rawToBeMapped, 123, 255, 0, 1023), HEX);
  mappedValue = map(rawToBeMapped, 123, 255, 0, 1023);
  Serial.println(mappedValue, HEX);
}

void loop() {}

you get 763DB6 and 3DB6 which shows what the compiler did, truncating the unsigned long's 4 bytes into the 2 LSB as per the C++ standard.

did I miss something?