nsdecimalnumber Questions

2

Solved

I need to decode (Decodable protocol) an imprecise decimal value correctly, from this question I understand how to properly handle the Decimal instantiation, but how can I do this when decoding? I...
Sailer asked 12/3, 2019 at 22:10

2

Solved

What data type I can use for parsing Java BigDecimal? In Objective - C it can be done by using NSDecimalNumber. Do I have Swift-native solution (without using NSDecimalNumber)?
Sodomy asked 23/8, 2016 at 20:44

6

Solved

I tried to convert Decimal to Int with the follow code: Int(pow(Decimal(size), 2) - 1) But I get: .swift:254:43: Cannot invoke initializer for type 'Int' with an argument list of type '(Decim...
Octonary asked 27/9, 2016 at 17:51

3

Solved

I am looking for a way to turn a NSDecimalNumber negative by multiplying by -1. /* decNumber is the one I would like to turn negative */ NSDecimalNumber *decNumber = [values objectAtIndex:billInde...
Syntax asked 20/2, 2011 at 15:26

4

Solved

How can I convert NSDecimalNumber values to String? // Return type is NSDecimalNumber var price = prod.minimumPrice // 10 // need a String cell.priceLB.text = NSString(format:"%f", prod.minimumPr...
Selfsame asked 21/1, 2017 at 8:9

3

Solved

I try to convert a String into a NSDecimalNumber here it my code: class func stringToDecimal (dataToDecimal: String) -> NSDecimalNumber { let dataToDecimal = dataToDecimal.stringByReplacingO...
Guidepost asked 13/11, 2015 at 20:38

1

Solved

We found an interesting case in our business logic that totally breaks our logic and we don't understand why NSDecimalNumber and Decimal behaves the way it does. My playground for the cases is as ...
Mound asked 8/5, 2019 at 8:34

1

Solved

I found a bug in my code that is caused by NSDecimalNumber.notANumber.intValue returning 9, while I would expect NaN (as floatValue or doubleValue return). Does anybody know why?
Colombia asked 7/1, 2019 at 12:20

2

Solved

If you have code such as this, then p will be "2.99": let price = 2.99 let p = String(format: "%.2f", price) However, if you have code like this: let priceNS: NSDecimalNumber =...
Tetradymite asked 3/10, 2017 at 22:22

4

Solved

OK team, this is weird. [NSDecimalNumber integerValue] is behaving strangely. I'm sat at a breakpoint, trying to figure out why some parts of my app are broken in iOS8, and I'm looking at a variab...
Array asked 6/9, 2014 at 22:52

4

Solved

For example, with primitive, I'll do this if ( (x >= 6000) && (x <= 20000) ) // do something here and with NSDecimalNumber, this is what I have if ( (([x compare:[NSNumber numbe...
Potts asked 27/1, 2012 at 6:44

1

Solved

I know float or double are not good for storing decimal number like money and quantity. I'm trying to use NSDecimalNumber instead. Here is my code in Swift playground. let number:NSDecimalNumber =...
Abysm asked 14/3, 2017 at 9:9

5

Solved

I'm retrieving a key from an object that looks like this: po obj { TypeID = 3; TypeName = Asset; } The key value is being retrieved like this: NSString *typeId = (NSString*)[obj objectForKey:...

5

Solved

I'm using NSDecimalNumber to store a value for currency. I'm trying to write a method called "cents" which returns the decimal portion of the number as an NSString with a leading 0 if the number is...
Dilks asked 18/3, 2011 at 17:34

3

Solved

I can't find any resources on this, and I've been trying all sorts of stuff, but nothing works. According to Apple's documentation, you round an NSDecimalNumber like this: NSDecimalNumber.decimal...
Gupta asked 26/6, 2015 at 10:25

2

I'm trying to get NSDecimalNumber to print out large numbers, 15 or more digits. At 15 digits I see 111,111,111,111,111. Above 15 digits I see 1,111,111,111,111,110 even though the number being for...
Deoxyribose asked 16/9, 2010 at 13:29

1

Solved

The following method takes input from a UITextField and formats it for display. This code has worked flawlessly for years, but a problem was just reported on the iPhone 6 Plus using iOS 8.1. It hap...
Booster asked 4/11, 2014 at 17:22

7

Solved

What's the easiest way to check if an instance of NSDecimalNumber is a whole number? Thanks!
Sekofski asked 6/9, 2012 at 11:9

3

Solved

Using 'num1' as a comparison reference to determine if 'num2' or 'num3' are zero. Have done this successfully in Objective-C, and am trying to do it in Swift: let num1: NSDecimalNumber = NSDecimal...
Anchises asked 14/6, 2014 at 19:27

2

I have two NSDecimalNumbers and I need to apply one to the power of the other, originally this code was using doubles and I could compute this with the pow() function like this: double result = po...
Balder asked 23/8, 2012 at 14:32

2

Solved

I realize that NSDecimalNumber inherits from NSNumber. However, I am struggling to figure out how I can init an NSDecimalNumber from an NSNumber or how to convert an NSNumber to an NSDecimalNumber...
Choctaw asked 5/2, 2014 at 5:50

1

Solved

For some reason, the comparing logic isn't working correctly... it wont compare two NSDecimalNumber objects. Sometimes it works, sometimes it doesn't. Really weird. The if statement works on some c...
Andraandrade asked 30/3, 2013 at 0:52

1

Solved

According to the documentation, [NSDecimalNumber decimalNumberWithString:] should use the locale decimal separator: Whether the NSDecimalSeparator is a period (as is used, for example, in the U...
Northamptonshire asked 20/3, 2013 at 20:48

3

Solved

I have a NSMutableArray which have some NSDecimalNumber in it, like (500,50.80,70,8000) Now I want to add all those decimal numbers together. I've tried to use for (NSDecimalNumber *number in s...
Murvyn asked 13/3, 2013 at 6:42

2

What is the conversion for NSString to NSDecimalNumber? unsigned long long order; if (i==1) { order = [feeArray objectAtIndex:0]; } if (i==2) { order = [amountArray objectAtIndex:0]; }
Phloem asked 10/7, 2012 at 7:37

© 2022 - 2024 — McMap. All rights reserved.