0

Currently creating an app which has to store fractions and then display them based on certain inputs.

However the fractions are complicated exam question style, for example:

2x^2 + 3

<hr />

3x^2 + 4

How can I display such a fraction as a string in swift?

Ramorie
  • 13
  • 3
  • https://stackoverflow.com/questions/29225779/how-to-use-subscript-and-superscript-in-swift – Bista Oct 17 '17 at 12:54
  • Since we are talking about Strings: Can you provide an example of input data and what kind of output you expect? -- Or do you want to render this beautifully? – ctietze Oct 17 '17 at 12:55
  • Thank you Mr.Bista, that does help me, however my main issue here is displaying the numerator with a line below it and the denominator below that. Any ideas? – Ramorie Oct 17 '17 at 12:59
  • ctietze ideally the strings will be stored in a data base and then accessed when a user searches for their tag. The fraction will then be presented nicely as it would be presented in a maths exam paper – Ramorie Oct 17 '17 at 13:00
  • 1
    Neither Swift nor the Foundation frameworks provide any methods to render mathematical expressions. But there are 3rd party libraries such as https://github.com/kostub/iosMath. See https://stackoverflow.com/questions/44228429/using-iosmath-in-swift for how to use it from Swift. – Martin R Oct 17 '17 at 13:24

0 Answers0