Questions tagged [nsdecimalnumber]

NSDecimalNumber, an immutable subclass of NSNumber, provides an object-oriented wrapper for doing base-10 arithmetic. An instance can represent any number that can be expressed as mantissa x 10^exponent where mantissa is a decimal integer up to 38 digits long, and exponent is an integer from –128 through 127.

NSDecimalNumber, an immutable subclass of NSNumber (), provides an object-oriented wrapper for doing base-10 arithmetic. An instance can represent any number that can be expressed as mantissa x 10^exponent where mantissa is a decimal integer up to 38 digits long, and exponent is an integer from –128 through 127.

244 questions
0
votes
2 answers

NSDecimalNumber multiplication weirdness

I've seen a similar topic about this a while back, but that seemed to be because the equation used NSNumber somewhere. I've checked all my code and all I can see is that I'm using NSDecimalNumbers for my equations. I got a JSON webservice that…
blaa
  • 438
  • 5
  • 19
0
votes
1 answer

Formatted absolute value of an NSNumber

Well, it's actually the sum of an array of NSDecimalNumbers I'd like to get the absolute value of... I constantly feel like I'm fighting the framework with all the conversions & typecasting that are required...from double to NSNumber to…
Meltemi
  • 37,979
  • 50
  • 195
  • 293
0
votes
1 answer

How does DecimalNumberByAdding work?

I have a situation which I need to add two NSDecimals and this is the code that I have: NSDecimalNumber *total = [[NSDecimalNumber alloc] initWithString:@"0"]; for (Product* product in cartItems) { NSDecimalNumber *prodPrice = [[NSDecimalNumber…
MaryamAyd
  • 151
  • 1
  • 9
0
votes
2 answers

How to convert NSDecimalNumber to double

I have a value being stored as an NSDecimalNumber and when I convert it to a double it's losing precision. For the current piece of data I'm debugging against, the value is 0.2676655. When I send it a doubleValue message, I get 0.267665. It's…
TJ Mott
  • 123
  • 4
  • 8
-1
votes
2 answers

how to store a value like "2.3.1" in Numbers in iOS?

I want to store a value something like 3.2.7 in Numbers in iOS, coz I want to compare the value with other. Is there any data type is available? or any tricks? anyone have a solution for this?
-1
votes
1 answer

A little confused about NSDecimalNumber?

there are a short code NSString *numString = @"2128.123123"; NSDecimalNumber *large = [NSDecimalNumber decimalNumberWithString:numString]; NSDecimalNumberHandler *decimalHandler = [NSDecimalNumberHandler…
-1
votes
1 answer

Find digit at index of NSDecimalNumber

Is it possible to find the number at an index of an NSDecimalNumber? For example is something like this possible? var a: NSDecimalNumber = 10.00123456789 var indexOfa = a(index: 6) //indexOfa = 6 (6th position from the left) I'm basically trying to…
LateNate
  • 763
  • 9
  • 22
-1
votes
2 answers

Display NSDecimalNumber in Cell's UILabel

I'm trying to display an NSDecimalNumber in a UILabel on my TableView Cell (I'm grabbing a price from BuyProductVariant). I can't seem to get the code right. The warning I get is: "Incompatible Pointer Types Assigning to NSString from …
Brittany
  • 1,359
  • 4
  • 24
  • 63
-1
votes
1 answer

Negate an NSDecimalNumber without losing the fractional part

I'm using this code to invert an NSDecimalNumber for easier arithmetic: self.thisTransaction.amount = [NSDecimalNumber decimalNumberWithString:self.amountField.text locale:NSLocale.currentLocale]; NSLog(@"1 thisTransaction.amount is…
rattletrap99
  • 1,469
  • 2
  • 17
  • 36
-1
votes
1 answer

NSMutableArray not adding NSDecimalNumber

I'm trying to add NSDecimalNumbers to an NSMutableArray. Here is the code: for (int i = 0; i < [dollarArray count]; i++) { NSString *string = [NSString stringWithFormat:@"%@.%@", [[firstArray objectAtIndex:i] firstObject], [[secondArray…
Horray
  • 693
  • 10
  • 25
-1
votes
1 answer

how to compare NSDecimalNumber in iOS

I have a price field which a NSDecimalNumber. I want to create a condition if the value is. I tried the following: - (NSString *)numberToPriceString:(NSDecimalNumber *)price{ NSDecimalNumber *zero = [[NSDecimalNumber alloc]…
Atma
  • 29,141
  • 56
  • 198
  • 299
-1
votes
1 answer

Error in NSDecimalNumberDivision: 'NSInvalidArgumentException', reason: '-[__NSCFNumber decimalNumberByDividingBy:]: unrecognized selector?

My code is // NSDecimalNumber *percentSpent = [distributionModel.spent decimalNumberByDividingBy:self.monthlySummaryModel.totalSpent]; // NSLog(@"percent:%@", percentSpent); NSLog(@"spent:%@, totalSpent:%@", distributionModel.spent,…
daydreamer
  • 87,243
  • 191
  • 450
  • 722
-1
votes
1 answer

What's the correct way to accumulate NSDecimalNumber values?

I am trying to accumulate NSDecimalNumber values obtained from an array (apptDataArray, obtained from a CoreData store; aCurrentCharges is defined as NSDecimalNumber). This is my code: NSDecimalNumber *accumulatedFees = 0; for(int i…
SpokaneDude
  • 4,856
  • 13
  • 64
  • 120
-1
votes
1 answer

iOS, Core Data: NSDecimalNumber result

I've created an Entity with attribute price with type NSDecimal. I try to count the sum of all prices in the entity: @property(nonatomic,strong)NSArray *coisArr; @property(nonatomic,strong)NSDecimalNumber *sum; _sum =[_coisArr…
NCFUSN
  • 1,624
  • 4
  • 28
  • 44
-1
votes
3 answers

Objective C : Get correct float values(justified)

I worked a lot in it and can't find a solution. Even the title can't explain clearly. I have three values weight, quantity and total I had done the following float wq = [[weightarray objectAtIndex:selectedint]floatValue]; float q = [quantity…
Nazik
  • 8,696
  • 27
  • 77
  • 123
1 2 3
16
17