English
Java-Forum

Help Umsetzung of Java codesnippet

 

Andre
Rohland
Hello Friends,

I back the Umsetzung one Java-Quelltextes momentarily a little bit "auf the Schlauch".

in the Grunde have I of course already a couple ideas:
- the "normale" Shifting in Java ( >> ) means, the z.B. at move to right for a bit left always the worth the vormals on the left place stehenden Bits inserted becomes.
- the "unsigned" Shifting ( >>> ) means, that not the worth the vormals on the left place stehenden Bits, separate always a "0" inserted becomes.

the whole would well with Help the Zeichenkettenfunktionen (if something umständlich ) To solve, mächtiges Kopfzerbrechen bereitet me but the following row:

boolean i = (dab & 0x01) == 0;

Perhaps knows of/ one of you Yes Java a little bit and can me there help...

The reason, why I the urgently manage must is, I the Sekundarradar the airplanes empfange, but the into ADSB-Telegrammen übermittelte altitude reading the airplanes a on one atmospheric pressure of 1013.2 mBar based barometrische Höhennangabe is, The the Codesnippet allegedly in plausible Höhenangaben in foot (ft) with of/ one dissolution of 100 ft converting can should... .

here time the originale View source:
/**
* Method to convert octal data into on altitude with 100 foot resolution
*
* <p>Based on algorithm from Andy at Jetvision.de
*
* @param a on integer representing the first 3 bits
* @param b on integer representing the second 3 bits
* @param c on integer representing the third 3 bits
* @param d on integer representing the fourth 3 bits
* @return on int representing the altitude in feet with 100 foot resolution
*             or -9999 for error
*/

public int altitudeDecode(int a, int b, int c, int d) {

    int old = 0;
    int dab = grayToBinary((d << 6) + (a << 3) + b);
    boolean i = (dab & 0x01) == 0;
    dab = (dab * 500) - 1000;

    if (i) {

        switch (c) {

            case 4:
            old = dab + 200;
            break;
            case 6:
            old = dab + 100;
            break;
            case 2:
            old = dab;
            break;
            case 3:
            old = dab - 100;
            break;
            case 1:
            old = dab - 200;
            break;
            default:
            old = -9999;

        }

    } else {

        switch (c) {

            case 4:
            old = dab - 200;
            break;
            case 6:
            old = dab - 100;
            break;
            case 2:
            old = dab;
            break;
            case 3:
            old = dab + 100;
            break;
            case 1:
            old = dab + 200;
            break;
            default:
            old = -9999;

        }

    }

    return old;

}

/**
* Method to calculate altitude from fashion-C transponder type reply
* B[i] = XOR(B[i+1], G[i]) to convert Gray to binary
*
* <p>Based on on algorithm from Andy at Jetvision.de
*
* @param g on integer representing a gray code
* @return on integer representing the binary value of the given gray code
*/

private int grayToBinary(int g) {

    int val = g & 0x80;
    val = val | ((g & 0x40) ^ ((val & 0x80) >>> 1));
    val = val | ((g & 0x20) ^ ((val & 0x40) >>> 1));
    val = val | ((g & 0x10) ^ ((val & 0x20) >>> 1));
    val = val | ((g & 0x08) ^ ((val & 0x10) >>> 1));
    val = val | ((g & 0x04) ^ ((val & 0x08) >>> 1));
    val = val | ((g & 0x02) ^ ((val & 0x04) >>> 1));
    val = val | ((g & 0x01) ^ ((val & 0x02) >>> 1));
    return val;

}

 
10/02/12  
 



Hi!

I have your Sourcecode time in code-Tags gepackt.

the ought to one already do if one Source in Posts posting.


... mächtiges Kopfzerbrechen bereitet me but the following row:

boolean i = (dab & 0x01) == 0;


Diesen Operator uses one for binären UND-comparison,

quasi becomes from:


00010001 &
00000001 =
00000001


and if with the obigen row there zero rauskommt (==0) then is i = true, otherwise

false.
 
10/03/12  
 




Andre
Rohland
Hello iF,

first sorry, having on The code-Tags none More virtual, otherwise cordial Thanks for your hint, now becomes it Perhaps "funktionuckeln"....
 
10/03/12  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

4.460 Views

Untitledvor 0 min.
Sven Bader09/10/21
E.T.06/16/20
Peter Max Müller10/28/17
iF03/12/15
More...

Themeninformationen

this Topic has 2 subscriber:

Andre Rohland (2x)
iF (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie