<commit_before>﻿// Original Work Copyright (c) <NAME> 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file

using System.Linq;

namespace EOLib.IO.Services
{
    public class NumberEncoderService : INumberEncoderService
    {
        public byte[] EncodeNumber(int number, int size)
        {
            var numArray = Enumerable.Repeat(254, 4).ToArray();
            var original = number;

            if (original >= NumericConstants.THREE_BYTE_MAX)
            {
                numArray[3] = number/NumericConstants.THREE_BYTE_MAX + 1;
                number = number%NumericConstants.THREE_BYTE_MAX;
            }

            if (original >= NumericConstants.TWO_BYTE_MAX)
            {
                numArray[2] = number/NumericConstants.TWO_BYTE_MAX + 1;
                number = number%NumericConstants.TWO_BYTE_MAX;
            }

            if (original >= NumericConstants.ONE_BYTE_MAX)
            {
                numArray[1] = number/NumericConstants.ONE_BYTE_MAX + 1;
                number = number%NumericConstants.ONE_BYTE_MAX;
            }

            numArray[0] = number + 1;

            return numArray.Select(x => (byte)x)<commit_msg>NumberEncoderService uses unsigned number to handle very large numbers properly.<commit_after>﻿// Original Work Copyright (c) <NAME> 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file

using System.Linq;

namespace EOLib.IO.Services
{
    public class NumberEncoderService : INumberEncoderService
    {
        public byte[] EncodeNumber(int number, int size)
        {
            var unsigned = (uint) number;
            var numArray = Enumerable.Repeat((uint)254, 4).ToArray();
            var original = unsigned;

            if (original >= NumericConstants.THREE_BYTE_MAX)
            {
                numArray[3] = unsigned / NumericConstants.THREE_BYTE_MAX + 1;
                unsigned = unsigned % NumericConstants.THREE_BYTE_MAX;
            }

            if (original >= NumericConstants.TWO_BYTE_MAX)
            {
                numArray[2] = unsigned / NumericConstants.TWO_BYTE_MAX + 1;
                unsigned = unsigned % NumericConstants.TWO_BYTE_MAX;
            }

            if (original >= NumericConstants.ONE_BYTE_MAX)
            {
                numArray[1] = unsigned / NumericConstants.ONE_BYTE_MAX + 1;
                unsigned = unsigned % NumericConstants.ONE_BYTE_MAX;
            }

            numArray[0] = unsigned + 1;

            return numArray.Select(x => (byte)x)
{'fraction_non_alphanumeric': 0.08471953578336557, 'fraction_numerical': 0.016247582205029015, 'mean_word_length': 2.0069767441860464, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '3617938', 'n_tokens_mistral': 748, 'n_tokens_neox': 694, 'n_words': 166}