[swift-users] Why no unsafeRemainder(dividingBy: Self) in FixedWidthInteger?

Jens Persson jens at bitcycle.com
Sun Oct 29 03:12:56 CDT 2017


I have some integer processing code that is called very intensively and
need to be as fast as possible, I therefore use &+ &- &/ &* instead of + -
/ * which results in a significant speedup.

However, I also need to use % and I noticed that there is no &% ...

That is, FixedWidthInteger has:
func remainderReportingOverflow(dividingBy: Self)

but there is no:
func unsafeRemainder(dividingBy: Self)

which is different from the other …ReportingOverflow-unsafe…-pairs:

func addingReportingOverflow(Self)
func subtractingReportingOverflow(Self)
func dividedReportingOverflow(by: Self)
func multipliedReportingOverflow(by: Self)

func unsafeAdding(Self)
func unsafeSubtracting(Self)
func unsafeMultiplied(by: Self)
func unsafeDivided(by: Self)

Is this intentional and if so why?

/Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171029/29d313e4/attachment.html>


More information about the swift-users mailing list