<commit_before>#include "../vendor/gc/include/gc.h"
#include "../vendor/gc/include/gc_cpp.h"
#include "../vendor/gc/include/gc_allocator.h"

#include <sstream>

#include "number.h"
#include "bootstrap/core_classes.h"

namespace fancy {

  Number::Number(double value) :
    FancyObject(NumberClass), _intval(0), _doubleval(value), _is_double(true)
  {
  }

  Number::Number(int value) :
    FancyObject(NumberClass), _intval(value), _doubleval(0), _is_double(false)
  {
  }

  FancyObject* Number::equal(FancyObject* other) const
  {
    if(!IS_NUM(other))
      return nil;

    return (NUMVAL(this) == NUMVAL(other)) ? t : nil;
  }

  EXP_TYPE Number::type() const
  {
    if(_is_double) {
      return EXP_DOUBLE;
    } else {
      return EXP_INTEGER;
    }
  }

  string Number::to_s() const
  {
    stringstream s;
    s << (is_double() ? _doubleval : _intval);
    return s.str();
  }

  double Number::doubleval() const
  {
    if(is_double()) {<commit_msg>src/number.cc: Higher precision for Number#to_s()<commit_after>#include "../vendor/gc/include/gc.h"
#include "../vendor/gc/include/gc_cpp.h"
#include "../vendor/gc/include/gc_allocator.h"

#include <sstream>

#include "number.h"
#include "bootstrap/core_classes.h"

namespace fancy {

  Number::Number(double value) :
    FancyObject(NumberClass), _intval(0), _doubleval(value), _is_double(true)
  {
  }

  Number::Number(int value) :
    FancyObject(NumberClass), _intval(value), _doubleval(0), _is_double(false)
  {
  }

  FancyObject* Number::equal(FancyObject* other) const
  {
    if(!IS_NUM(other))
      return nil;

    return (NUMVAL(this) == NUMVAL(other)) ? t : nil;
  }

  EXP_TYPE Number::type() const
  {
    if(_is_double) {
      return EXP_DOUBLE;
    } else {
      return EXP_INTEGER;
    }
  }

  string Number::to_s() const
  {
    stringstream s;
    s.precision(1000); // for preciser output of numbers
    s << (is_double() ? _doubleval : _intval);
    return s.str();
  }

  double Number::doubleval() const
  {
    if(is_double()) {
{'fraction_non_alphanumeric': 0.15521502718734553, 'fraction_numerical': 0.003954522985664854, 'mean_word_length': 3.4483516483516485, 'pattern_counts': {'":': 0, '<': 9, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1721310', 'n_tokens_mistral': 757, 'n_tokens_neox': 735, 'n_words': 134}