diff options
Diffstat (limited to 'MLKInteger.m')
-rw-r--r-- | MLKInteger.m | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/MLKInteger.m b/MLKInteger.m index 7239f0b..10c3bca 100644 --- a/MLKInteger.m +++ b/MLKInteger.m @@ -29,6 +29,13 @@ return self; } +-(MLKInteger *) initWithInt:(int)intValue +{ + self = [super init]; + mpz_init_set_si (value, intValue); + return self; +} + -(MLKInteger *) initWithString:(NSString *)string negative:(BOOL)negative base:(unsigned int)base @@ -53,6 +60,12 @@ base:base]); } ++(MLKInteger *) integerWithInt:(int)intValue +{ + return AUTORELEASE ([[MLKInteger alloc] initWithInt:intValue]); +} + + #define DEFINE_MPZ_TWOARG_OPERATION(SELECTOR, GMPFUN) \ DEFINE_GMP_OPERATION (SELECTOR (MLKInteger *)arg, \ mpz, \ @@ -65,6 +78,7 @@ DEFINE_MPZ_TWOARG_OPERATION (subtract:, mpz_sub) DEFINE_MPZ_TWOARG_OPERATION (multiplyWith:, mpz_mul) DEFINE_MPZ_TWOARG_OPERATION (divideBy:, mpz_div) + -(int) intValue { return mpz_get_si (value); |