Dystlab uses its own math engine, MathSIV©, in its digital products. This high-tech tool allows you to perform mathematical calculations, solve systems of equations, convert expressions into symbolic (analytical) form, perform numerical and symbolic differentiation and integration, and more. MathSIV supports real numbers ("-2.5", "4.6e8", "Pi"), complex numbers ("2+3.2I"), one-, two-, and three-dimensional vectors and matrices ("M=[1 2 3]"), logical data types ("if{x<1}(a b)"), and physical quantities with arbitrary units (A=2.5 mm^2).


Точність математичних обчислень

Усі обчислення в MathSIV© виконуються з подвійною машинною точністю. Це дозволяє системі оперувати додатніми та від'ємними числами в діапазоні 2.23×10⁻³⁰⁸ .. 1.79e×10³⁰⁸, кожне з яких зберігє до 16 знаків після десяткового роздільника.

Формат відображення чисел

Для багатьох технічних розрахунків вказана точність є "надмірною" і виникає потреба в округленні.

В усіх продуктах Dystlab ви можете гнучко керувати форматом відображення чисел на екрані. Таке округлення не впливає на дійсні значення параметрів, адже використовується лише в демонстраційних цілях. Наприклад, в об'єктах автоматизації Math Object або Slider в програмі TechEditor ви можете вказати потрібну кількість знаків після десяткового роздільника:

Dystlab MathSIV | Tolerance

Для налаштування формату зазвичай використовується окремий селектор Format, який розташовано в секції Output поруч з полем для математичного виразу:

Dystlab MathSIV | Output section

Тут %1.1f є специфікатором, який задає потрібний формат округлення числа (див. нижче).

Способи форматування дійсних чисел

  • %g — General format. The value is converted to the shortest possible decimal string using fixed or scientific format. The number of significant digits in the resulting string is given by the precision specifier in the format string; a default precision of 15 is assumed if no precision specifier is present. Trailing zeros are removed from the resulting string, and a decimal point appears only if necessary. The resulting string uses the fixed-point format if the number of digits to the left of the decimal point in the value is less than or equal to the specified precision, and if the value is greater than or equal to 0.00001. Otherwise the resulting string uses scientific format (%e);
  • %e — Scientific format. The value is converted to a string of the form "-d.ddd...E+ddd". The resulting string starts with a minus sign if the number is negative. One digit always precedes the decimal point. The total number of digits in the resulting string (including the one before the decimal point) is given by the precision specifier in the format string; a default precision of 15 is assumed if no precision specifier is present. The "E" exponent character in the resulting string is always followed by a plus or minus sign and at least three digits;
  • %f — Fixed format. The argument must be a floating-point value. The value is converted to a string of the form "-ddd.ddd...". The resulting string starts with a minus sign if the number is negative. The number of digits after the decimal point is given by the precision specifier in the format string — a default of 2 decimal digits is assumed if no precision specifier is present;

До кожного із вказаних специфікаторів можна додавати цифри, які вказиватимуть на кількість знаків після крапки, наприклад:

  • %1.2f — число округлюється до 2 знака;
  • %1.4f — число округлюється до 4 знака, і т. п.

У випадку фізичної величини, форматується лише її числове значення; одиниці вимірювання додаються до результату, після округлення.

Інші специфікатори

В ситуаціях, не пов'язаних з математичними обчисленнями (як-от в програмуванні застосунків), можуть також використовуватися додаткові специфікатори:

  • %d — Decimal. The argument must be an integer value. The value is converted to a string of decimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has less digits, the resulting string is left-padded with zeros;
  • %n — Number. The argument must be a floating-point value. The value is converted to a string of the form "-d,ddd,ddd.ddd...". The n format corresponds to the f format, except that the resulting string contains thousand separators;
  • %s — String. The argument must be a character, a string, or a PChar value. The string or character is inserted in place of the format specifier. The precision specifier, if present in the format string, specifies the maximum length of the resulting string. If the argument is a string that is longer than this maximum, the string is truncated.

Приклади форматування чисел

Універсальний формат (%g)

1/3=0.333333333333333
2+3.1^6=889.503681
Pi=3.14159265358979
sin((32 °))=0.529919264233205

Фіксований формат (%f)

1/3=0.33
2+3.1^6=889.50
Pi=3.14
sin((32 °))=0.53

Фіксований формат з округленням до 3 знаків після крапки (%.3f)

1/3=0.333
2+3.1^6=889.504
Pi=3.142
sin((32 °))=0.530

Науковий формат (%e)

1/3=3.33333333333333E-001
2+3.1^6=8.89503681000000E+002
Pi=3.14159265358979E+000
sin((32 °))=5.29919264233205E-001

Науковий формат з округленням до 3 знаків після крапки (%.3e)

1/3=3.33E-001
2+3.1^6=8.90E+002
Pi=3.14E+000
sin((32 °))=5.30E-001