mercredi 20 janvier 2016

Why is this int comparison failing?

Value of unparsedString at the breakpoint:

101010ten十<img src="E58D81.png" />ten, needle21Turn this character 45 degrees either way and you have the x used for the Roman numeral <b>ten</b>.* As a primitive, this character sometimes keeps its meaning of <i>ten</i> and sometimes signifies <i>needle</i>, this latter derived from the kanji for <i>needle</i> (Frame 292). Since the primitive is used in the kanji itself, there is no need to worry about confusing the two. In fact, we shall be following this procedure regularly.Two needles crossing marks the spot, or you can use the Roman character for ten (rotated 45 degrees).I scared away ten vampires with a single cross!15ジュウ、ジッ、ジュッとお、と十分(じっぷん): 10 minutes<br>十字路(じゅうじろ): crossroads<br>五十音(ごじゅうおん): the Japanese syllabary<br>十分(じゅうぶん): enough<br>十(じゅう): 10, ten<br>十(とお): 10, ten<br>十日(とおか): ten days, the tenth day of the month<br>二十歳(はたち): 20 years old, 20th year<br>二十日(はつか): twenty days, twentieth day of the month十字架 (じゅうじか), 十文字 (じゅうもんじ), 十 (と), 十 (とお)

ParseKanji method:

 protected Kanji parseKanji(String unparsedString) {
    Kanji kanji = new Kanji();
    String[] fields = unparsedString.split("\u001F");

    int onI = findKatakanaIndex(fields); //17 while debugging
    int kunI = onI + 1;  //18, also checked

    kanji.setMeaning(fields[3]);
    kanji.setCharacter(fields[4]);
    kanji.setJH(fields[onI - 2]);
    kanji.setJTPL(fields[onI - 1]);
    kanji.setOnReading(fields[onI]);

    if (fields.length < kunI){ //returns false
    kanji.setKunReading(fields[onI + 1]);
    } else {
    Log.d("MyTests",  fields.length + " < " + kunI);
    Log.d("MyTests",  kanji.getCharacter() + " does not have a kun Reading");
    }

    return kanji;
}

Logcat:

21 < 18
十 does not have a kun Reading

Note that I previously was comparing by using onI + 1 and the output from logcat was:

21 < 171
十 does not have a kun Reading

Aucun commentaire:

Enregistrer un commentaire