Format a boolean into an existing array.
Overload List
Name | Description | |
---|---|---|
![]() |
format (Boolean, Byte) | Format a boolean into an existing array. |
![]() |
format (Boolean, Byte, Int32, Int32) | Format a boolean into an existing array |
![]() |
format (Double, Byte) | Format a double into an array. |
![]() |
format (Double, Byte, Int32, Int32) | Format a double into an existing character array. This is hard to do exactly right... The JDK code does stuff with rational arithmetic and so forth. We use a much simpler algorithm which may give an answer off in the lowest order bit. Since this is pure Java, it should still be consistent from machine to machine. Recall that the binary representation of the double is of the form d = 0.bbbbbbbb x 2n where there are up to 53 binary digits in the binary fraction (including the assumed leading 1 bit for normalized numbers). We find a value m such that 10m d is between 253 and >263. This product will be exactly convertible to a long with no loss of precision. Getting the decimal representation for that is trivial (see formatLong). This is a decimal mantissa and we have an exponent (-m). All we have to do is manipulate the decimal point to where we want to see it. Errors can arise due to roundoff in the scaling multiplication, but should be no more than a single bit. |
![]() |
format (Int32, Byte) | Format an int into an array. |
![]() |
format (Int32, Byte, Int32, Int32) | Format an int into an existing array. |
![]() |
format (Int64, Byte) | Format a long into an array. |
![]() |
format (Int64, Byte, Int32, Int32) | Format a long into an existing array. |
![]() |
format (Single, Byte) | Format a float into an array. |
![]() |
format (Single, Byte, Int32, Int32) | Format a float into an existing byteacter array. This is hard to do exactly right... The JDK code does stuff with rational arithmetic and so forth. We use a much simpler algorithm which may give an answer off in the lowest order bit. Since this is pure Java, it should still be consistent from machine to machine. Recall that the binary representation of the float is of the form d = 0.bbbbbbbb x 2n where there are up to 24 binary digits in the binary fraction (including the assumed leading 1 bit for normalized numbers). We find a value m such that 10m d is between 224 and >232. This product will be exactly convertible to an int with no loss of precision. Getting the decimal representation for that is trivial (see formatInteger). This is a decimal mantissa and we have an exponent (-m). All we have to do is manipulate the decimal point to where we want to see it. Errors can arise due to roundoff in the scaling multiplication, but should be very small. |
![]() |
format (String, Byte) | Insert a string at the beginning of an array |
![]() |
format (String, Byte, Int32, Int32) | Insert a String into an existing character array. If the String is longer than len, then only the the initial len characters will be inserted. |