Buggy code:
public class StringFormatter { @ CompilerDirectives . TruffleBoundary public static String format ( RubyContext context , String format , List < Object > values ) { } @ CompilerDirectives . TruffleBoundary public static void format ( RubyContext context , PrintStream stream , String format , List < Object > values ) { int n = 0 ; int v = 0 ; int lengthModifier ; while ( n < ( format . length ( ) ) ) { final char c = format . charAt ( n ) ; n ++ ; if ( c == '%' ) { final String flagChars = "0" ; boolean zeroPad = false ; while ( ( n < ( format . length ( ) ) ) && ( ( flagChars . indexOf ( format . charAt ( n ) ) ) != ( - 1 ) ) ) { switch ( format . charAt ( n ) ) { case '0' : zeroPad = true ; break ; default : break ; } n ++ ; } int width ; if ( ( n < ( format . length ( ) ) ) && ( Character . isDigit ( format . charAt ( n ) ) ) ) { final int widthStart = n ; while ( Character . isDigit ( format . charAt ( n ) ) ) { n ++ ; } width = Integer . parseInt ( format . substring ( widthStart , n ) ) ; } else { width = 0 ; } int precision ; if ( ( format . charAt ( n ) ) == '.' ) { n ++ ; final int precisionStart = n ; while ( Character . isDigit ( format . charAt ( n ) ) ) { n ++ ; } precision = Integer . parseInt ( format . substring ( precisionStart , n ) ) ; } else { precision = 6 ; } if ( ( format . charAt ( n ) ) == '<seq2seq4repair_space>' ) { n ++ ; final int lengthStart = n ; while ( Character . isDigit ( format . charAt ( n ) ) ) { n ++ ; } lengthModifier = Integer . parseInt ( format . substring ( lengthStart , n ) ) ; } else { lengthModifier = 0 ; } final char type = format . charAt ( n ) ; n ++ ; final StringBuilder formatBuilder = new StringBuilder ( ) ; formatBuilder . append ( "%" ) ; if ( width > 0 ) { if ( zeroPad ) { formatBuilder . append ( "0" ) ; } formatBuilder . append ( width ) ; } switch ( type ) { case '%' : { stream . print ( "%" ) ; break ; } case 's' : { formatBuilder . append ( "s" ) ; stream . printf ( formatBuilder . toString ( ) , DebugOperations . send ( context , values . get ( v ) , "to_s" , null ) ) ; break ; } case 'x' : case 'X' : case 'd' : { if ( lengthModifier != 0 ) { formatBuilder . append ( "<seq2seq4repair_space>" ) ; formatBuilder . append ( lengthModifier ) ; } formatBuilder . append ( type ) ; final Object value = values . get ( v ) ; final long longValue ; if ( value instanceof Integer ) { longValue = ( ( int ) ( value ) ) ; } else if ( value instanceof Long ) { longValue = ( ( long ) ( value ) ) ; } else { throw new UnsupportedOperationException ( ) ; } stream . printf ( formatBuilder . toString ( ) , longValue ) ; break ; } case 'f' : { formatBuilder . append ( "." ) ; formatBuilder . append ( precision ) ; formatBuilder . append ( "f" ) ; final double value = CoreLibrary . toDouble ( values . get ( v ) ) ; stream . printf ( formatBuilder . toString ( ) , value ) ; break ; } case 'g' : { final double value = CoreLibrary . toDouble ( values . get ( v ) ) ; <START_BUG> if ( value == ( ( long ) ( value ) ) ) { <END_BUG> stream . print ( String . valueOf ( ( ( long ) ( value ) ) ) ) ; } else { stream . print ( String . valueOf ( value ) ) ; } break ; } default : throw new RuntimeException ( ( "Kernel#sprintf<seq2seq4repair_space>error<seq2seq4repair_space>--<seq2seq4repair_space>unknown<seq2seq4repair_space>format:<seq2seq4repair_space>" + type ) ) ; } if ( type != '%' ) { v ++ ; } } else { stream . print ( c ) ; } } } }

Fix:
if ( ( value - ( Math . rint ( value ) ) ) == 0 ) {