Adding large Power values in Xcode

前端 未结 2 1663
南旧
南旧 2021-01-28 14:33

I am new to Objective C and iPhone development.

I\'m working with a basic calculator. I want to add a large value in text field. How can I display large values like this

相关标签:
2条回答
  • 2021-01-28 14:47

    Use Double data type. And then convert it into string then pass that string to your textField.

    For eg:-

    double result;
    NSString *strResult = [[NSNumber numberWithDouble:result] stringValue];
    

    It will give you exponential string.

    And instead of a UILabel use UITextField.

    0 讨论(0)
  • 2021-01-28 15:10

    You could set up a NSNumberFormatter with NSNumberFormatterScientificStyle and call stringFromNumber... However, the issue I think is going to be with the precision you are hoping to support requires a specialized framework. There might be one based on GNU MP Bignum library out there, but I don't know it off hand.

    0 讨论(0)
提交回复
热议问题