Question
Swift. Trying to convert decimal to fraction. Can NumberFormatter (https://developer.apple.com/documentation/foundation/numberformatter) help me convert decimal to fraction? If so can you help me convert with my
Swift. Trying to convert decimal to fraction. Can NumberFormatter (https://developer.apple.com/documentation/foundation/numberformatter) help me convert decimal to fraction? If so can you help me convert with my sample code? If not what are my other options?
var maximumFractionDigits: Int { get set }
===============code==============================
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textF: UITextField!
@IBOutlet weak var answer: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func enter(_ sender: Any) {
Double(textF.text!) == nil
var guessNumber = Double(textF.text!);
var maximumFractionDigits = guessNumber //not declare correctly open to sugguestion
answer.text = "\(guessNumber!) "
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started