objective c - NSDecimalNumber from NSString not equal? -


i've got weirdest thing happening.

code:

nsstring *input = @"357835487953487345879345897345897345897534"; nslog(@"%@", input); nsdecimalnumber *number = [nsdecimalnumber decimalnumberwithstring:input]; nslog(@"%@", number); 

output:

 357835487953487345879345897345897345897534  357835487953487345879345897345897345890000 

so number's aren't same, has accuracy of floating point numbers. can these equal? why replacing last few digits zero?

check documentation nsdecimalnumber

nsdecimalnumber, immutable subclass of nsnumber, provides object-oriented wrapper doing base-10 arithmetic. instance can represent number can expressed mantissa x 10^exponent mantissa decimal integer 38 digits long, , exponent integer –128 through 127.

when run code same until 38th digit:

357835487953487345879345897345897345897534 357835487953487345879345897345897345890000


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -