<commit_before>#include "freicoinunits.h"

#include <QStringList>

FreicoinUnits::FreicoinUnits(QObject *parent):
        QAbstractListModel(parent),
        unitlist(availableUnits())
{
}

QList<FreicoinUnits::Unit> FreicoinUnits::availableUnits()
{
    QList<FreicoinUnits::Unit> unitlist;
    unitlist.append(FRC);
    unitlist.append(mFRC);
    unitlist.append(uFRC);
    return unitlist;
}

bool FreicoinUnits::valid(int unit)
{
    switch(unit)
    {
    case FRC:
    case mFRC:
    case uFRC:
        return true;
    default:
        return false;
    }
}

QString FreicoinUnits::name(int unit)
{
    switch(unit)
    {
    case FRC: return QString("FRC");
    case mFRC: return QString("mFRC");
    case uFRC: return QString::fromUtf8("μFRC");
    default: return QString("???");
    }
}

QString FreicoinUnits::description(int unit)
{
    switch(unit)
    {
    case FRC: return QString("Freicoins");
    case mFRC: return QString("Milli-Freicoins (1 / 1,000)");
    case uFRC: return QString("Micro-Freicoins (1 / 1,000,000)");
    default: return QString("???");
    }
}

mpq FreicoinUnits::factor(int unit)
{
    switch(unit)
    {
    case FRC:  return 100000000;
    case mFRC: return 100000;
    case uFRC: return 100;
    default:   return 100000000;
    }
}

int FreicoinUnits::amountDigits(int unit)
{
    switch(unit)
    {
    case FRC: return 9; // 100,000,000 (# digits, without commas)
    case mFRC: return 12; // 100,000,000,000
    case uFRC: return 15; // 100,000,000,000,000
    default: return 0;
    }
}

int FreicoinUnits::decimals(int unit)
{
    switch(unit)
    {
    case FRC: return 8;
    case mFRC: return 5;
    case uFRC: return 2;
    default: return 0;<commit_msg>Restructure FreicoinUnits::factor() method to make it clearer that it is returning an mpq value and that FRC is the default.<commit_after>#include "freicoinunits.h"

#include <QStringList>

FreicoinUnits::FreicoinUnits(QObject *parent):
        QAbstractListModel(parent),
        unitlist(availableUnits())
{
}

QList<FreicoinUnits::Unit> FreicoinUnits::availableUnits()
{
    QList<FreicoinUnits::Unit> unitlist;
    unitlist.append(FRC);
    unitlist.append(mFRC);
    unitlist.append(uFRC);
    return unitlist;
}

bool FreicoinUnits::valid(int unit)
{
    switch(unit)
    {
    case FRC:
    case mFRC:
    case uFRC:
        return true;
    default:
        return false;
    }
}

QString FreicoinUnits::name(int unit)
{
    switch(unit)
    {
    case FRC: return QString("FRC");
    case mFRC: return QString("mFRC");
    case uFRC: return QString::fromUtf8("μFRC");
    default: return QString("???");
    }
}

QString FreicoinUnits::description(int unit)
{
    switch(unit)
    {
    case FRC: return QString("Freicoins");
    case mFRC: return QString("Milli-Freicoins (1 / 1,000)");
    case uFRC: return QString("Micro-Freicoins (1 / 1,000,000)");
    default: return QString("???");
    }
}

mpq FreicoinUnits::factor(int unit)
{
    switch(unit)
    {
    case uFRC: return mpq("100/1");
    case mFRC: return mpq("100000/1");
    default:
    case FRC:  return mpq("100000000/1");
    }
}

int FreicoinUnits::amountDigits(int unit)
{
    switch(unit)
    {
    case FRC: return 9; // 100,000,000 (# digits, without commas)
    case mFRC: return 12; // 100,000,000,000
    case uFRC: return 15; // 100,000,000,000,000
    default: return 0;
    }
}

int FreicoinUnits::decimals(int unit)
{
    switch(unit)
    {
    case FRC: return 8;
    case mFRC: return 5;
    case uFRC: return 2;
    default: return 0;
{'fraction_non_alphanumeric': 0.1338426711941143, 'fraction_numerical': 0.04753820033955857, 'mean_word_length': 3.2083333333333335, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 3, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5253090', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1306, 'n_words': 290}