Try this illustrative demo:
fileName = 'Delete_me.jpg';
fileName = 'Delete_me.png';
fileName = 'Delete_me.mat';
As you can see if it's a floating point number, imwrite will expect the number to be in the range 0-1 and it will multiply it by 255 and then cast to uint8. Numbers below 0 get clipped to 0, and numbers above 1 get clipped to 1 (so they'll be recalled as 255).
Moreover, run it a few times and you will probably see that the JPG recalled numbers are slightly different than the PNG numbers because of the lossy compression. So that's why you should use PNG, which is pretty much now a de facto standard format that most people use, and not JPG (which image analysts hate because it changes the values).
If you want to save the fractional part of the numbers then you should use MATLAB's proprietary format .MAT which will recall the floating point image with all its original, unchanged values.
I'm not sure exactly what you mean when you say "I am interested in reproducing this effect." What effect? What does "reproduce" mean to you.