[Library Scripts] String Maths by B O F

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Post Reply
B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

[Library Scripts] String Maths by B O F

Post by B-O'F » Sun, 30. Mar 08, 17:12

String Maths Library

V1 - 2008/02/30


Do you want to use really large numbers?

Do you want to use really small numbers?

Do you need to mix really large numbers and small numbers?

Do you wish you could use decimal numbers?


This could be the answer to your problems.

This is a package to support arithmetic operations on numeric strings - O.K. I named it String Maths, but it is really String Arithmetic..

It works on:-
- numeric strings,
- signed numeric strings - leading or trailing signs.
- decimal strings (sign optional).

It performs:-
- '+' Add
- '-' Subtract
- '*' Multiply
On decimal and/or non-decimal strings.

- '/' Divide - non-decimal returns quotient and remainder in an array, decimal returns a decimal string.
- '//' Forced Divide - return a decimal result from two non-decimal input strings.

It currently supports a choice of two decimal point characters - main.44 uses a full stop while main.49 uses a comma.
You can add your own character to use as a decimal point if you require it. Instructions are in the "Usage" file and in the main.xx scripts themselves.

You can also select whether to have leading '+' signs included or not - there is no choice for negative result strings, they will always have a leading '-' sign.

Decimal output is to a default of 20 decimal places, if either input string has more, then that is taken as the default. It also includes rounding to the selected number of places.

The output is normally a signed string, the exceptions are:-
- Non-decimal divide will return an array of quotient and remainder.
- An error will return a NUMBER, not a string. See "Usage" for how to cope with these different outputs.

The only ouput message from the basic library is from the main.xx - if you specify a decimal point string rather than a single character.
The additional script to format the output for display does issue error mesages, as it is also meant for stand-alone use.


This package contains:
* All the scripts required to perform the above.
* The ReadMe text which gives more information about the package.
* The Usage text which has information on how to use the package and the error returns.
* Various texts describing the methods and problems implementing this package.
* The scripts in text format for perusal (don't laugh too loudly).

* It also contains a straight text list of all the Editor commands.

All in a .zip file, ready for you to use as you wish.

Available courtesy of Xai Corporation String Maths
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Post Reply

Return to “X³: Reunion - Scripts and Modding”