espruino/EspruinoDocs — pull request #24 by zigrin (2014-01-27 13:53:18+00:00)
Title: Remove _mapRes() method

Hi Gordon, here is an idea - save up about 35-40 vars (memory) by using some math formulas and removing fairly big chunk of code.

As a consequence, setting and getting conversion resolution will take longer, but it doesn't really matter because these operations are normally executed only a few times (if any) in your program. In contrast, memory savings are there all the time. Also if I correctly understand the way code gets executed in Espruino, this change would actually increase the performance for common operations like temperature reading.

What I don't like about this solution is that these formulas use a lot of magic numbers and so the code readability suffers... but that's the best working formulas I could come up with. Maybe some binary-ninja will jump in and improve them.