import { ToDecimal } from './addition'; import { InternalBiggerThan } from './arimetic'; import { equals } from '../../../comparison/infrastructure'; import { join, split } from '../../../strings/infrastructure'; import { forceExtract, forceToString } from '../../../internals'; import { forceConcat, Pop } from '../../../arrays-and-tuples/app'; import { CarryOnAddition, DecimalHashMap } from '../domain'; type substractMap = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]; type substractMapForCarry = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]; type GetSustract = forceExtract, forceExtract>; type getSustractCarry = B extends forceExtract> ? 1 : 0; type sustractDecimal, B>> = { result: Result; carryOut: $if<(equals & equals), { then: 1; else: getSustractCarry; }>; }; type _SubstractOnShifted = sustractDecimal>, ToDecimal>, CarryIn>; type _next> = MakeSubstractOnTuple, forceExtract, forceConcat<[forceExtract], lastIncompleteResult>, forceExtract>; type removeZeros = T extends [infer C, ...infer R] ? C extends 0 ? removeZeros : T : T; type MakeSubstractOnTuple = A extends [] ? removeZeros : _next, Pop, Result, CarryIn>; type MakeSubstract = InternalBiggerThan extends true ? `-${join>}` : join>; export type InternalSubstract>, split>>> = R extends '' ? 0 : R extends `${infer X extends number}` ? X : never; export {};