lang: funcs: core: math: Add a fortytwo function

This is mainly meant as a useful test case, but might as well have it be
fun too. As an aside, it taught me a surprising result about the %v verb
in printf, and we'll have to decide if it's an issue we care about.

https://github.com/golang/go/issues/46118

The interesting thing about this method is that it uses the simplepoly
API but has no input args-- only the output types are different. If it
had identical types in the input args, that might also have been
interesting, but it's more rare to have none. Hopefully this exercises
our type unification logic.
This commit is contained in:
James Shubin
2021-05-12 03:28:19 -04:00
parent fe2b8c9fee
commit b3d1ed9e65
5 changed files with 86 additions and 0 deletions

View File

@@ -708,6 +708,7 @@ func NewFloat() *FloatValue { return &FloatValue{} }
// String returns a visual representation of this value.
func (obj *FloatValue) String() string {
// TODO: is this the right display mode?
// FIXME: floats don't print nicely: https://github.com/golang/go/issues/46118
return strconv.FormatFloat(obj.V, 'f', -1, 64) // -1 for exact precision
}