PokéRogue
    Preparing search index...

    Type Alias Subtract<A, B>

    Subtract: number extends A
    | B
        ? number
        : A extends B & (PositiveInfinity | NegativeInfinity)
            ? number
            : A extends NegativeInfinity
                ? NegativeInfinity
                : B extends PositiveInfinity
                    ? NegativeInfinity
                    : A extends PositiveInfinity
                        ? PositiveInfinity
                        : B extends NegativeInfinity
                            ? PositiveInfinity
                            : A extends B
                                ? 0
                                : A extends 0
                                    ? ReverseSign<B>
                                    : B extends 0 ? A : SubtractPostChecks<A, B>

    Returns the difference between two numbers.

    Note:

    • A or B can only support -999 ~ 999.

    Type Parameters

    • A extends number
    • B extends number
    import type {Subtract, PositiveInfinity} from 'type-fest';

    type A = Subtract<333, 222>;
    //=> 111

    type B = Subtract<111, -222>;
    //=> 333

    type C = Subtract<-111, 222>;
    //=> -333

    type D = Subtract<18, 96>;
    //=> -78

    type E = Subtract<PositiveInfinity, 9999>;
    //=> Infinity

    type F = Subtract<PositiveInfinity, PositiveInfinity>;
    //=> number