logo separator

[mkgmap-dev] methods to write signed / unsigned integers

From Gerd Petermann GPetermann_muenchen at hotmail.com on Thu Feb 15 10:06:23 GMT 2018


we have various methods to write an integer with 1, 2, 3, or 4 bytes to an img file.
I always feel unsure what method to use because none of them makes
clear what happens with negative values.

Besides that some of the existing routines seem to throw misleading exceptions, 
e.g. FileBackedImgFileWriter seems to assume that it is only used for the mdr tmp file and creates texts like this:
throw new MapFailedException("could not write3 to mdr tmp file");
throw new MapFailedException("could not write put3 to mdr tmp file"); 

Only the javadoc for put1() and put2() tell me the range (0..255 or 0..65535) .

If I got that right put3() allows negative values, so I think it is NOT 0..16777215 but -8388608 .. 8388607 ?

I'd like to improve the readability of the code, but I don't want to mess up anything.
Would it be possible to add comments to all the methods?


More information about the mkgmap-dev mailing list