<commit_before>package main

import (
	"strconv"

	"github.com/sev3ryn/aritmo/parse"
	"github.com/sev3ryn/aritmo/scan"
)

const precision = 2

func RoundFloat(x float64, prec int) float64 {
	f, _ := strconv.ParseFloat(strconv.FormatFloat(x, 'g', prec, 64), 64)
	return f
}

func calculate(input string) string {
	p := parse.New(scan.New(input))
	output, err := p.ExecStatement()
	if err != nil {
		return ""
	}

	output = RoundFloat(output, precision+1)

	return strconv.FormatFloat(output, 'f', -1, 64)
<commit_msg>fixed issue with round func<commit_after>package main

import (
	"math"
	"strconv"

	"github.com/sev3ryn/aritmo/parse"
	"github.com/sev3ryn/aritmo/scan"
)

const precision = 2

func RoundFloat(x float64, prec int) float64 {
	if math.IsNaN(x) || math.IsInf(x, 0) {
		return x
	}

	sign := 1.0
	if x < 0 {
		sign = -1
		x *= -1
	}

	var rounder float64
	pow := math.Pow(10, float64(prec))
	intermed := x * pow
	_, frac := math.Modf(intermed)

	if frac >= 0.5 {
		rounder = math.Ceil(intermed)
	} else {
		rounder = math.Floor(intermed)
	}

	return rounder / pow * sign
}

func calculate(input string) string {
	p := parse.New(scan.New(input))
	output, err := p.ExecStatement()
	if err != nil {
		return ""
	}

	output = RoundFloat(output, precision)

	return strconv.FormatFloat(output, 'f', -1, 64)

{'fraction_non_alphanumeric': 0.1491628614916286, 'fraction_numerical': 0.02968036529680365, 'mean_word_length': 3.6964285714285716, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6654579', 'n_tokens_mistral': 567, 'n_tokens_neox': 518, 'n_words': 123}