ds_set_precision

Sets the precision used for comparisons.

Syntax:

GML Code Example

ds_set_precision(prec);


Argument Description
prec The precision value (default 0.0000001)


Returns: N/A


Description

When comparing values, for example when searching in a map or sorting a list, GameMaker: Studio must decide when two values are equal. For strings and integer values this is clear but for real numbers, due to floating point round-off errors, seemingly equal numbers can easily become unequal. For example, it's possible that (5 / 3) * 3 will not be equal to 5! To help avoid this, a precision value is used on all real number functions, and when the difference between two numbers is smaller than this precision they are considered equal. The default a precision of 0.0000001 is used for all data structure functions unless changed by this function.

NOTE: This precision is used in all data structures but not in other comparisons in GML!


Example:

GML Code Example

ds_set_precision(0.0001);

The above code will change the default precision setting for all data structure functions.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here