<commit_before>package router.configuration;

/**
 *
 * @author mathias
 */
public class SpeedHelper {
    public static final String USERTYPE_BROWSING = "Browsing";
    public static final String USERTYPE_DOWNLOADING = "Downloading";
    
    public static int calculateSpeed(String capable, String profile) {
        int capableSpeed = Integer.parseInt(capable);
        int advisedSpeed = capableSpeed;
        if(capableSpeed > 1000) {
            if(profile.equals(USERTYPE_BROWSING)) //Don't overdo usage for people just wanting to browse (we don't want to drive them away due to resource hogging)
                advisedSpeed *= 0.6;
            else if(profile.equals(USERTYPE_DOWNLOADING))
                advisedSpeed *= 0.8;
        }
        else
            advisedSpeed *= 0.6; //Lower available bandwidth: don't hog all the bandwidth
        return advisedSpeed;
    }
    
    public static int calculateMonthlyUsage(int kbytes) {
        return (kbytes*3600*24*31)/1000000;
    }
}<commit_msg>Fixed overflow problem when calculating monthly usage. It now works well (without  getting too wide for the window) up to 1 Tbps.<commit_after>package router.configuration;

/**
 *
 * @author mathias
 */
public class SpeedHelper {
    public static final String USERTYPE_BROWSING = "Browsing";
    public static final String USERTYPE_DOWNLOADING = "Downloading";
    
    public static int calculateSpeed(String capable, String profile) {
        int capableSpeed = Integer.parseInt(capable);
        int advisedSpeed = capableSpeed;
        if(capableSpeed > 1000) {
            if(profile.equals(USERTYPE_BROWSING)) //Don't overdo usage for people just wanting to browse (we don't want to drive them away due to resource hogging)
                advisedSpeed *= 0.6;
            else if(profile.equals(USERTYPE_DOWNLOADING))
                advisedSpeed *= 0.8;
        }
        else
            advisedSpeed *= 0.6; //Lower available bandwidth: don't hog all the bandwidth
        return advisedSpeed;
    }
    
    public static int calculateMonthlyUsage(int kbytes) {
        return (int) ((((long)kbytes)*3600*24*31)/1000000);
    }
}
{'fraction_non_alphanumeric': 0.08364312267657993, 'fraction_numerical': 0.023698884758364312, 'mean_word_length': 2.7249134948096887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4666936', 'n_tokens_mistral': 630, 'n_tokens_neox': 573, 'n_words': 184}