I am converting a C ++ program into Java and completely trapped in the following method, Blown up. Would you love to explain that what this method is doing?
Tall TSBC :: GetSignedValue (Constant Ndita String and Values) {Fixed NDataString s; S = value; Long multiplier (1); Size_t lane (S. lane ()); If (lane! = 0) {if (s [0]> = (four) 0xB0 & amp; 0] [lt; = (four) 0xB9) {S [0] & amp; = 0x7F; // bit pattern: 01111111 multiplier = -1; } And if (S [lane-1]> gt (=) 0xB0 & amp; [Lennon-1] & lt; = (four) 0xB9) {S [Lane -1] & amp; = 0x7F; // bit pattern: 01111111 multiplier = -1; } Second multiplier = 1; } Second multiplier = 1; Return s.ToLong () * Multiplier; My initial Java version: Get long personal property (last string value) {byte [] bytes = value.getBytes (); Int length = bytes. Lamps; Long multiplier = 1 l; If (bytes.exe; gt; 0) {if (bytes [0]> = (four) 0xB0 and bytes [0] gt; = (four) 0xB0 and bytes [length - 1] & lt; = (four) 0xB9) {bytes [length - 1] & amp; = 0x7F; // bit pattern: 01111111 multiplier = -1; } Second multiplier = 1; } Second multiplier = 1; Return long. Arrays.toString (bytes) * Multiplier; }
Am I correct?
It is taking a byte string (i.e. no text) and for this a long execution of this multiple Depends on things, and looks broken: It is removing the sign bit from two different places. Another issue is unnecessary non-reintercing (due to static variables).
No comments:
Post a Comment