I'd like to do "basic math" on large (64-bits) signed integers in a "DSL" (jsonnet) that only has support for "numbers" (64-bit double). My "strategy" is converting strings, representing "integer" user-input, that can be correctly represented as a number into one, and on every "operation" just check which parameters are "number" and "strings".
Ideally, I'd have support for add, sub, mult, div, modulo and comparisons. But I can build modulo using div, and sub using add (assuming add support signed integers). Comparisons should be easy too.
So, at the very least, I'd need add, mult, and ideally div implementation examples.
There are a bunch of example out there, but all the ones I found either assume that there is an integer type that can contain the biggest integer, or that the language is procedural. Unfortunately, jsonnet is also functional, and so procedural solutions cannot simply be used either.
So, what I'm looking for is an example (or link to one), that shows me how to add, multiply, and ideally divide, signed integers, represented as strings, using the functional paradigm, without using some "built-in" library function to do the hard work (unless it's also available in jsonnet). Or, most likely, the OSS implementation of that built-in library function.
I'm not overly concerned with performance, but I'm hoping for an O(m + n) rather than O(m * n) solution ...
I think (although not authoritative on this) that you'll need to add jsonnet native functions to handle int64 and wanted operators. Jsonnet golang libs do provide an interface to add these, I've crafted an (incomplete) example that should help: