jOOQ / jOOU

jOOU - Unsigned Integers jOOU provides unsigned integer versions for the four Java integer types byte, short, int and long.
http://www.jooq.org/products
Apache License 2.0
229 stars 32 forks source link

Create UMath #11

Closed elect86 closed 7 years ago

elect86 commented 8 years ago

UMath class

At the moment I only wrote min, max

However I'd like to expand it with glm common functions such as mix, step, clamp, uintBitsToFloat, etc..

elect86 commented 8 years ago

I'd also like to add methods to each unsigned type for multiplication and division as well..

elect86 commented 8 years ago

May I also ask why constructors are privates and value final?

lukaseder commented 8 years ago

However I'd like to expand it with glm common functions such as mix, step, clamp, uintBitsToFloat, etc..

Hmm, what are those? Would you mind sharing what they do and why they're generally useful?

I'd also like to add methods to each unsigned type for multiplication and division as well..

Sure, great idea. The naming of these methods would ideally match that of BigInteger and BigDecimal

May I also ask why constructors are privates and value final?

These classes are value types. Users should not be allowed to construct them manually, or modify the final value. Do note that Number constructors (such as Integer(int)) are finally deprecated in Java 9, as they should be: http://download.java.net/java/jdk9/docs/api/java/lang/Integer.html#Integer-int-

sirikid commented 7 years ago

Since unsigned numbers in JOOU are classes we don't need these overloads:

static <T extends Comparable<T>> min(T a, T b) {
    return a.compareTo(b) < 0 ? a : b;
}

static <T extends Comparable<T>> max(T a, T b) {
    return a.compareTo(b) > 0 ? a : b;
}
lukaseder commented 7 years ago

@sirikid You're right, thanks for the feedback. Given the limited advantage of having actual methods called min() and max() over the comparison with the compareTo() result, I'm going to reject this PR for now, as there are currently no other useful UMath method proposals.

elect86 commented 7 years ago

Hi Lukas,

just wanted to say sorry if I didn't show up further, but I got totally keen up on Kotlin now, and I am switching definitely to it...

Thanks anyway for your avaialbility and sorry again! Giuseppe

lukaseder commented 7 years ago

@elect86 : Hey, no worries at all. Totally understand!

sirikid commented 7 years ago

@elect86 Kotlin is addictive language :^) I'm also tried to write jOOU analogue in Kotlin, it isn't easy as it might seem at first glance.