gvergnaud / hotscript

A library of composable functions for the type-level! Transform your TypeScript types in any way you want using functions you already know.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for fractional numbers with Numbers types

TetroGem opened this issue · comments

Currently, trying to use a non-integer will only perform the operation on the integer portion of the number:

import { Apply, Numbers } from "hotscript";

type DoubleHalf = Apply<Numbers.Mul, [0.5, 2]>; // evaluates to 0
type DoubleTwoPointFive = Apply<Numbers.Mul, [2.5, 2]>; // evaluates to 4

Playground link

Couldn't find any mention of it on this repo, so just was wondering if this is unintentional, planned to be implemented, or not being added?

commented

It's not supported indeed. Would it be possible ? Definitely.
Is it worth implementing it ? depends on use cases.
The already implemented number features are already borderline useful.

To answer the question, i was not planning on adding floating point capability.
But PR are welcomed.
I would however suggest anyone interested in implementing it to Implement it Using a Floats namespace to not have impact on the Numbers perf