Map function question

Hi all.

I have a question about the map function.

I see there is a lot of talk on git hub about it.

But here is my question, I want to map the values 0 - 4095 to 0 - 100

I use the function like this

val = map(4095,0,4095,0,100);

I am expecting 100 to return if I send in 4095 but I am getting 87.

Am I missing something ?

Am I missing something ?

The rest of your code. And proof.

void setup() {
  Serial.print(F("map(4095, 0, 4095, 0, 100) = "));
  Serial.println(map(4095, 0, 4095, 0, 100));
void loop() {}
map(4095, 0, 4095, 0, 100) = 100

Thank all, I found the problem. Putty changed one of my values.

Putty changed one of my values.

How did it do that ?

How did it do that ?

Hi UKHeliBob.

I develop on the Rapberry Pi. I have the Arduino hooked up to the Pi. I ported the Map function to Python and used it in a very long line of code that runs up to the end of the nano editor, I used the mark and copy method between 2 putty sessions and I copied the $ by mistake, I then went in to fix it and probably hit the 9 and not the 0, As the error was at the end of the line I did not pick it up as nano will jump the line if it is to long.

As I got the map function from the Arduino source I decided to post it here after reading some posts about the map not working. I made a mistake. Thanks for the help.