Buggy code:
double computed ; StringBuilder sb = new StringBuilder ( ) ; write ( ( "Stats<seq2seq4repair_space>for<seq2seq4repair_space>scenario<seq2seq4repair_space>" + ( getScenarioName ( ) ) ) ) ; if ( bReportRawData ) { reportRawData ( sb ) ; } write ( "\nOFFLOADING:" ) ; for ( DTNHost host : mNodes . keySet ( ) ) { OffloadingReport . SingleNodeReport report = mNodes . get ( host ) ; responseTimes . addAll ( report . getResponseTimes ( ) ) ; latencies . addAll ( report . getLatencies ( ) ) ; sb . append ( "Node<seq2seq4repair_space>" ) ; sb . append ( host . toString ( ) ) ; sb . append ( "<seq2seq4repair_space>-<seq2seq4repair_space>Requests:<seq2seq4repair_space>" ) ; amount = report . getAmountOfRequests ( ) ; sb . append ( amount ) ; totalRequests += amount ; reports = report . getP2POffloadedReports ( ) ; offloaded1 = reports . size ( ) ; p2pOffloadedRequests += offloaded1 ; sb . append ( ",<seq2seq4repair_space>P2P:<seq2seq4repair_space>" ) ; sb . append ( offloaded1 ) ; byteOffloaded1 = countReceivedBytes ( reports ) ; reports = report . getWifiOffloadedReports ( ) ; offloaded2 = reports . size ( ) ; wifiOffloadedRequests += offloaded2 ; sb . append ( ",<seq2seq4repair_space>WiFi:<seq2seq4repair_space>" ) ; sb . append ( offloaded2 ) ; byteOffloaded2 = countReceivedBytes ( reports ) ; sb . append ( ",<seq2seq4repair_space>Total<seq2seq4repair_space>offloaded:<seq2seq4repair_space>" ) ; sb . append ( ( offloaded1 + offloaded2 ) ) ; offloadedRequests . add ( ( ( double ) ( offloaded1 + offloaded2 ) ) ) ; percentage = computePercentage ( amount , ( offloaded1 + offloaded2 ) ) ; sb . append ( ",<seq2seq4repair_space>Percentage:<seq2seq4repair_space>" ) ; sb . append ( format ( percentage ) ) ; offloadedRequestsPercentage . add ( percentage ) ; sb . append ( "%,<seq2seq4repair_space>Failed<seq2seq4repair_space>requests:<seq2seq4repair_space>" ) ; failed = report . getFailedRequests ( ) ; totalFailed += failed ; sb . append ( failed ) ; sb . append ( ";<seq2seq4repair_space>Bytes:<seq2seq4repair_space>" ) ; bytes = report . getTotalReceivedBytes ( ) ; totalBytes += bytes ; sb . append ( ( ( long ) ( bytes ) ) ) ; p2pOffloadedBytes += byteOffloaded1 ; sb . append ( ",<seq2seq4repair_space>P2P:<seq2seq4repair_space>" ) ; sb . append ( ( ( long ) ( byteOffloaded1 ) ) ) ; wifiOffloadedBytes += byteOffloaded2 ; sb . append ( ",<seq2seq4repair_space>WiFi:<seq2seq4repair_space>" ) ; sb . append ( ( ( long ) ( byteOffloaded2 ) ) ) ; sb . append ( ",<seq2seq4repair_space>Total<seq2seq4repair_space>offloaded:<seq2seq4repair_space>" ) ; sb . append ( ( ( long ) ( byteOffloaded1 + byteOffloaded2 ) ) ) ; offloadedBytes . add ( ( byteOffloaded1 + byteOffloaded2 ) ) ; percentage = computePercentage ( bytes , ( byteOffloaded1 + byteOffloaded2 ) ) ; sb . append ( ",<seq2seq4repair_space>Percentage:<seq2seq4repair_space>" ) ; sb . append ( format ( percentage ) ) ; sb . append ( "%" ) ; offloadedBytesPercentage . add ( percentage ) ; write ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; } sb . append ( "\nTotal<seq2seq4repair_space>Requests:<seq2seq4repair_space>" ) ; sb . append ( totalRequests ) ; sb . append ( ",<seq2seq4repair_space>P2P:<seq2seq4repair_space>" ) ; sb . append ( p2pOffloadedRequests ) ; sb . append ( ",<seq2seq4repair_space>WiFi:<seq2seq4repair_space>" ) ; sb . append ( wifiOffloadedRequests ) ; sb . append ( ",<seq2seq4repair_space>Total<seq2seq4repair_space>offloaded:<seq2seq4repair_space>" ) ; sb . append ( ( p2pOffloadedRequests + wifiOffloadedRequests ) ) ; percentage = computePercentage ( totalRequests , ( p2pOffloadedRequests + wifiOffloadedRequests ) ) ; sb . append ( ",<seq2seq4repair_space>Percentage:<seq2seq4repair_space>" ) ; sb . append ( format ( percentage ) ) ; sb . append ( "%,<seq2seq4repair_space>Failed:<seq2seq4repair_space>" ) ; sb . append ( totalFailed ) ; sb . append ( "\nTotal<seq2seq4repair_space>Bytes:<seq2seq4repair_space>" ) ; sb . append ( ( ( long ) ( totalBytes ) ) ) ; sb . append ( ",<seq2seq4repair_space>P2P:<seq2seq4repair_space>" ) ; sb . append ( ( ( long ) ( p2pOffloadedBytes ) ) ) ; sb . append ( ",<seq2seq4repair_space>WiFi:<seq2seq4repair_space>" ) ; sb . append ( ( ( long ) ( wifiOffloadedBytes ) ) ) ; sb . append ( ",<seq2seq4repair_space>Total<seq2seq4repair_space>offloaded:<seq2seq4repair_space>" ) ; <START_BUG> sb . append ( ( ( ( long ) ( p2pOffloadedBytes ) ) + wifiOffloadedBytes ) ) ; <END_BUG> percentage = computePercentage ( totalBytes , ( p2pOffloadedBytes + wifiOffloadedBytes ) ) ; sb . append ( ",<seq2seq4repair_space>Percentage:<seq2seq4repair_space>" ) ; sb . append ( format ( percentage ) ) ; sb . append ( "%" ) ; write ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; Collections . sort ( offloadedRequests ) ; write ( "\nOFFLOADED<seq2seq4repair_space>REQUESTS<seq2seq4repair_space>PER<seq2seq4repair_space>NODE:" ) ; sb . append ( "ABSOLUTE<seq2seq4repair_space>-<seq2seq4repair_space>" ) ; sb . append ( "Mean:<seq2seq4repair_space>" ) ; computed = computeMeanValue ( offloadedRequests ) ; sb . append ( format ( computed ) ) ; sb . append ( ",<seq2seq4repair_space>Median:<seq2seq4repair_space>" ) ; computed = computeMedianValue ( offloadedRequests ) ; sb . append ( format ( computed ) ) ; sb . append ( ",<seq2seq4repair_space>95%tile:<seq2seq4repair_space>" ) ; computed = compute95Percentile ( offloadedRequests ) ; sb . append ( format ( computed ) ) ; sb . append ( ",<seq2seq4repair_space>Min:<seq2seq4repair_space>" ) ; computed = computeMinValue ( offloadedRequests ) ; sb . append ( format ( computed ) ) ; sb . append ( ",<seq2seq4repair_space>Max:<seq2seq4repair_space>" ) ; computed = computeMaxValue ( offloadedRequests ) ; sb . append ( format ( computed ) ) ; sb . append ( "\nPERCENTAGE<seq2seq4repair_space>-<seq2seq4repair_space>" ) ; sb . append ( "Mean:<seq2seq4repair_space>" ) ; computed = computeMeanValue ( offloadedRequestsPercentage ) ; sb . append ( format ( computed ) ) ; sb . append ( "%,<seq2seq4repair_space>Median:<seq2seq4repair_space>" ) ; computed = computeMedianValue ( offloadedRequestsPercentage ) ; sb . append ( format ( computed ) ) ; sb . append ( "%,<seq2seq4repair_space>95%tile:<seq2seq4repair_space>" ) ; computed = compute95Percentile ( offloadedRequestsPercentage ) ; sb . append ( format ( computed ) ) ; sb . append ( "%,<seq2seq4repair_space>Min:<seq2seq4repair_space>" ) ; computed = computeMinValue ( offloadedRequestsPercentage ) ; sb . append ( format ( computed ) ) ; sb . append ( "%,<seq2seq4repair_space>Max:<seq2seq4repair_space>" ) ; computed = computeMaxValue ( offloadedRequestsPercentage ) ; sb . append ( format ( computed ) ) ;

Fix:
sb . append ( ( ( long ) ( p2pOffloadedBytes + wifiOffloadedBytes ) ) ) ;