ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.37k stars 2.51k forks source link

Proposal: promote std.math.divCeil to @divCeil builtin #16022

Open wooster0 opened 1 year ago

wooster0 commented 1 year ago

This is a proposal to promote std.math.divCeil to a @divCeil builtin.

This discussion is very relevant: https://github.com/ziglang/zig/pull/15879#discussion_r1208557275

The main reason here would be that if we have @divExact, @divFloor, and @divTrunc, we should have @divCeil too.

From the past, the only real argument against it in #4095 seems to be:

It should only be a builtin if this is something that has a matching instruction on some CPU. Otherwise it just goes into the standard library.

However, quoting @jacobly0:

I'm also not aware of a cpu with a @divFloor instruction

so the question is why isn't @divFloor demoted to a standard library function?

buzmeg commented 4 days ago

Quoting: @jacobly0 @wooster0 :

I'm also not aware of a cpu with a @divFloor instruction

CUDA is an example which has those intrinsics.

See: https://docs.nvidia.com/cuda/floating-point/index.html

__fdiv__ [rn | rz | ru | rd] (x, y)