VOOZH about

URL: https://docs.json-everything.net/api/JsonSchema.Net/JsonMath/

⇱ JsonMath Class | json-everything


👁 avatar
json-everything
Library documentation
Home JsonMath Class
JsonMath Class
Cancel

JsonMath Class

Namespace: Json.Schema

Inheritance: JsonMath 🡒 object

Provides static methods for performing mathematical operations and comparisons on JSON numeric values represented by System.Text.Json.JsonElement instances.

Remarks

The methods in this class are designed to work directly with the textual representation of JSON numbers, enabling precise comparison and divisibility checks without converting to .NET numeric types. This is useful for scenarios where exact JSON number semantics are required, such as schema validation or custom JSON

Methods

Divides(JsonElement dividend, JsonElement divisor)

Determines whether the numeric value represented by the specified JSON element is evenly divisible by the value of another JSON element.

Declaration

1
public static bool Divides(JsonElement dividend, JsonElement divisor)
ParameterTypeDescription
dividendJsonElementThe JSON element representing the dividend. Must contain a valid numeric value.
divisorJsonElementThe JSON element representing the divisor. Must contain a valid numeric value.

Returns

true if the dividend is evenly divisible by the divisor; otherwise, false.

Remarks

Both parameters must represent valid JSON numbers. If the divisor is zero or not a valid number,

IsInteger(JsonElement value)

Determines whether the numeric value represented by the specified JSON element is a mathematical integer (i.e. has no fractional part), without converting to a .NET numeric type.

Declaration

1
public static bool IsInteger(JsonElement value)
ParameterTypeDescription
valueJsonElementA System.Text.Json.JsonElement whose System.Text.Json.JsonElement.ValueKind must be

Returns

Contents

A new version of content is available.