Buggy code:
public class ReportCurrencyUtils { private BigDecimal amount ; public ReportCurrencyUtils ( long l ) { } public ReportCurrencyUtils ( double l ) { } public ReportCurrencyUtils ( String strValue ) { } public String asString ( ) { } public String num2str ( ) { } public String num2str ( boolean stripkop ) { <START_BUG> amount = amount . setScale ( 2 , RoundingMode . FLOOR ) ; <END_BUG> String [ ] [ ] kind = new String [ ] [ ] { new String [ ] { "" , "один" , "два" , "три" , "четыре" , "пять" , "шесть" , "семь" , "восемь" , "девять" } , new String [ ] { "" , "одна" , "две" , "три" , "четыре" , "пять" , "шесть" , "семь" , "восемь" , "девять" } } ; String [ ] strHundreds = new String [ ] { "" , "сто" , "двести" , "триста" , "четыреста" , "пятьсот" , "шестьсот" , "семьсот" , "восемьсот" , "девятьсот" } ; String [ ] strTeens = new String [ ] { "" , "десять" , "одиннадцать" , "двенадцать" , "тринадцать" , "четырнадцать" , "пятнадцать" , "шестнадцать" , "семнадцать" , "восемнадцать" , "девятнадцать" , "двадцать" } ; String [ ] strTens = new String [ ] { "" , "десять" , "двадцать" , "тридцать" , "сорок" , "пятьдесят" , "шестьдесят" , "семьдесят" , "восемьдесят" , "девяносто" } ; String [ ] [ ] forms = new String [ ] [ ] { new String [ ] { "копейка" , "копейки" , "копеек" , "1" } , new String [ ] { "рубль" , "рубля" , "рублей" , "0" } , new String [ ] { "тысяча" , "тысячи" , "тысяч" , "1" } , new String [ ] { "миллион" , "миллиона" , "миллионов" , "0" } , new String [ ] { "миллиард" , "миллиарда" , "миллиардов" , "0" } , new String [ ] { "триллион" , "триллиона" , "триллионов" , "0" } } ; long rub = amount . longValue ( ) ; String [ ] moi = amount . toString ( ) . split ( "\\." ) ; long kop = Long . valueOf ( moi [ 1 ] ) ; if ( ! ( moi [ 1 ] . substring ( 0 , 1 ) . equals ( "0" ) ) ) { if ( kop < 10 ) kop *= 10 ; } String kops = String . valueOf ( kop ) ; if ( ( kops . length ( ) ) == 1 ) kops = "0" + kops ; long rub_tmp = rub ; ArrayList segments = new ArrayList ( ) ; while ( rub_tmp > 999 ) { long seg = rub_tmp // 1000 ; segments . add ( ( rub_tmp - ( seg * 1000 ) ) ) ; rub_tmp = seg ; } segments . add ( rub_tmp ) ; Collections . reverse ( segments ) ; String o = "" ; if ( rub == 0 ) { o = "ноль<seq2seq4repair_space>" + ( morph ( 0 , forms [ 1 ] [ 0 ] , forms [ 1 ] [ 1 ] , forms [ 1 ] [ 2 ] ) ) ; if ( stripkop ) return o ; else return ( ( ( o + "<seq2seq4repair_space>" ) + kop ) + "<seq2seq4repair_space>" ) + ( morph ( kop , forms [ 0 ] [ 0 ] , forms [ 0 ] [ 1 ] , forms [ 0 ] [ 2 ] ) ) ; } int level = segments . size ( ) ; for ( int i = 0 ; i < ( segments . size ( ) ) ; i ++ ) { int sexi = Integer . valueOf ( forms [ level ] [ 3 ] . toString ( ) ) ; int currentSegment = Integer . valueOf ( segments . get ( i ) . toString ( ) ) ; if ( ( currentSegment == 0 ) && ( level > 1 ) ) { level -- ; continue ; } String rs = String . valueOf ( currentSegment ) ; if ( ( rs . length ( ) ) == 1 ) rs = "00" + rs ; if ( ( rs . length ( ) ) == 2 ) rs = "0" + rs ; int firstDigit = Integer . valueOf ( rs . substring ( 0 , 1 ) ) ; int secondDigit = Integer . valueOf ( rs . substring ( 1 , 2 ) ) ; int thirdDigit = Integer . valueOf ( rs . substring ( 2 , 3 ) ) ; int secondAndThirdDigit = Integer . valueOf ( rs . substring ( 1 , 3 ) ) ; if ( currentSegment > 99 ) o += ( strHundreds [ firstDigit ] ) + "<seq2seq4repair_space>" ; if ( secondAndThirdDigit > 20 ) { o += ( strTens [ secondDigit ] ) + "<seq2seq4repair_space>" ; o += ( kind [ sexi ] [ thirdDigit ] ) + "<seq2seq4repair_space>" ; } else { if ( secondAndThirdDigit > 9 ) o += ( strTeens [ ( secondAndThirdDigit - 9 ) ] ) + "<seq2seq4repair_space>" ; else o += ( kind [ sexi ] [ thirdDigit ] ) + "<seq2seq4repair_space>" ; } o += ( morph ( currentSegment , forms [ level ] [ 0 ] , forms [ level ] [ 1 ] , forms [ level ] [ 2 ] ) ) + "<seq2seq4repair_space>" ; level -- ; } if ( stripkop ) { o = o . replaceAll ( "<seq2seq4repair_space>{2,}" , "<seq2seq4repair_space>" ) ; } else { o = ( ( ( o + "" ) + kops ) + "<seq2seq4repair_space>" ) + ( morph ( kop , forms [ 0 ] [ 0 ] , forms [ 0 ] [ 1 ] , forms [ 0 ] [ 2 ] ) ) ; o = o . replaceAll ( "<seq2seq4repair_space>{2,}"

Fix:
amount = amount . setScale ( 2 , RoundingMode . HALF_UP ) ;