
-----------------------------------
Joji
Wed Oct 26, 2011 12:29 pm

Superscript and Rounding Issues
-----------------------------------
What is it you are trying to achieve?
I am trying to figure out how to do a superscript in Turing. Here is the question:
2.1.14 Write a program that let you enter two numbers a,b, and that prints out a^b
I am also trying to figure out how to round numbers to 3 digits behind the decimal point.

What is the problem you are having?
I checked google, search bar, and the forums, but couldn't find the answer to how I could do a superscript in Turing like you would in Microsoft Office.
As for rounding, I used google, search bar, and the forums, but still no luck.

Describe what you have tried to solve this problem
Here is my attempted code:
Please specify what version of Turing you are using
Turing 4.1.1

Many thanks. :)

-----------------------------------
Tony
Wed Oct 26, 2011 12:44 pm

RE:Superscript and Rounding Issues
-----------------------------------
1. look closely at how superscript appears -- it's a slightly smaller font that's moved up from the line. You can't do that with put but you have all of the control over font sizes and positioning with [tdoc]Font.Draw[/tdoc], so you could figure things out there.

2. syntax/documentation -- [tdoc]round[/tdoc]

-----------------------------------
Joji
Wed Oct 26, 2011 12:51 pm

RE:Superscript and Rounding Issues
-----------------------------------
Tony, I want to round to 3 decimal places. How would I type that out.

-----------------------------------
Tony
Wed Oct 26, 2011 1:42 pm

RE:Superscript and Rounding Issues
-----------------------------------
e.g. you want to round 1.234 to 2 decimal places. You then take a note that round(123.4) returns 123 -- just the digits you want. You'd just need to move the decimal point back to where it was -- 1.23;

rounding to any number of places works the same way. Rounding to 0 places is a "special case" where some steps are simplified away.

-----------------------------------
Raknarg
Tue Nov 01, 2011 5:38 pm

RE:Superscript and Rounding Issues
-----------------------------------
You could also use text manipulation. Convert it to a string, shorten it how you like and then convert it back into a decimal.

-----------------------------------
Tony
Tue Nov 01, 2011 5:55 pm

RE:Superscript and Rounding Issues
-----------------------------------
Besides the performance hit, it simply seems like more work to track where in the string the decimal point is. String truncation would also act as floor(), not round().
