<commit_before>package runtime

import (
	"math"

	"github.com/ta2gch/iris/runtime/environment"
	"github.com/ta2gch/iris/runtime/ilos"
	"github.com/ta2gch/iris/runtime/ilos/class"
	"github.com/ta2gch/iris/runtime/ilos/instance"
)

// The value of MostPositiveFloat is the implementation-dependent
// ﬂoating-point number closest to positive infinity.
//
// The value of MostNegativeFloat is the implementation-dependent
// ﬂoating-point number closest to negative infinity.
var (
	MostPositiveFloat = instance.New(class.Float, math.MaxFloat64)
	MostNegativeFloat = instance.New(class.Float, -math.MaxFloat64)
)

// Floatp returns t if obj is a ﬂoat (instance of class float);
// otherwise, returns nil. The obj may be any ISLISP object.
func Floatp(_, _ *environment.Environment, obj ilos.Instance) (ilos.Instance, ilos.Instance) {
	if instance.Of(class.Float, obj) {
		return T, nil
	}
	return Nil, nil
}

// Float returns x itself if it is an instance of the class float
// and returns a ﬂoating-point approximation of x otherwise.
// An error shall be signaled if x is not a number (error-id. domain-error).
func Float(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Float, f), nil
}

// Floor returns the greatest integer less than or equal to x .
// That is, x is truncated towards negative infinity. An error
// shall be signaled if x is not a number (error-id. domain-error).
func Floor(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Integer, int(math.Floor(f))), nil
}

// Ceiling Returns the smallest integer that is not smaller than x.
// That is, x is truncated towards positive infinity. An error
// shall be signaled if x is not a number (error-id. domain-error).
func Ceiling(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Integer, int(math.Ceil(f))), nil
}

// Truncate returns the integer between 0 and x (inclusive) that is nearest to x.
// That is, x is truncated towards zero. An error shall be signaled
// if x is not a number (error-id. domain-error).
func Truncate(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Integer, int(math.Trunc(f))), nil
}

// Round returns the integer nearest to x.
//  If x is exactly halfway between two integers, the even one is chosen.
// An error shall be signaled if x is not a number (error-id. domain-error).
func Round(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Integer, int(math.Floor(f+.5))), nil
}<commit_msg>Changed comment<commit_after>package runtime

import (
	"math"

	"github.com/ta2gch/iris/runtime/environment"
	"github.com/ta2gch/iris/runtime/ilos"
	"github.com/ta2gch/iris/runtime/ilos/class"
	"github.com/ta2gch/iris/runtime/ilos/instance"
)

// The value of MostPositiveFloat is the implementation-dependent
// ﬂoating-point number closest to positive infinity.
//
// The value of MostNegativeFloat is the implementation-dependent
// ﬂoating-point number closest to negative infinity.
var (
	MostPositiveFloat = instance.New(class.Float, math.MaxFloat64)
	MostNegativeFloat = instance.New(class.Float, -math.MaxFloat64)
)

// Floatp returns t if obj is a ﬂoat (instance of class float);
// otherwise, returns nil. The obj may be any ISLISP object.
func Floatp(_, _ *environment.Environment, obj ilos.Instance) (ilos.Instance, ilos.Instance) {
	if instance.Of(class.Float, obj) {
		return T, nil
	}
	return Nil, nil
}

// Float returns x itself if it is an instance of the class float
// and returns a ﬂoating-point approximation of x otherwise.
// An error shall be signaled if x is not a number (error-id. domain-error).
func Float(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Float, f), nil
}

// Floor returns the greatest integer less than or equal to x .
// That is, x is truncated towards negative infinity. An error
// shall be signaled if x is not a number (error-id. domain-error).
func Floor(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Integer, int(math.Floor(f))), nil
}

// Ceiling Returns the smallest integer that is not smaller than x.
// That is, x is truncated towards positive infinity. An error
// shall be signaled if x is not a number (error-id. domain-error).
func Ceiling(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Integer, int(math.Ceil(f))), nil
}

// Truncate returns the integer between 0 and x (inclusive) that is nearest to x.
// That is, x is truncated towards zero. An error shall be signaled
// if x is not a number (error-id. domain-error).
func Truncate(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Integer, int(math.Trunc(f))), nil
}

// Round returns the integer nearest to x.
// If x is exactly halfway between two integers, the even one is chosen.
// An error shall be signaled if x is not a number (error-id. domain-error).
func Round(_, _ *environment.Environment, x ilos.Instance) (ilos.Instance, ilos.Instance) {
	f, _, err := convFloat64(x)
	if err != nil {
		return nil, err
	}
	return instance.New(class.Integer, int(math.Floor(f+.5))), nil
}
{'fraction_non_alphanumeric': 0.11817427385892117, 'fraction_numerical': 0.006639004149377593, 'mean_word_length': 3.847948511665326, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3477613', 'n_tokens_mistral': 2019, 'n_tokens_neox': 1933, 'n_words': 689}