Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Scientific notation
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jay




PostPosted: Fri Feb 25, 2005 10:18 am   Post subject: Scientific notation

Hey all. Out of boredom (and to put off studying) I decided to write a program to output Pascal's triangle, as well as calculate nCr. I started off using nats, but ran into a problem where the factorial function that I wrote would overflow the nat or int type once I tried to calculate anything greater than 13! or so. I then moved to using real, which now allows me to calculate up to 169!, which I'm sure is well outside the realm of practical use (which is good). The problem is when I try to output the triangle or individual nCr values, once I get to the row where n = 23, I start to generate numbers in scientific notation. My question is, in C++ you can use IOS flags to prevent the use of scientific notation and instead force decimal, can you do something similar in Turing? Also, is there already a factorial function that I just failed to find? I looked in the reference under math and didn't see anything, so I just wrote my own.

Is this the kind of thing that I should submit in the submission forum when I'm done?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Feb 25, 2005 11:15 am   Post subject: (No subject)

there're some output flags available in turing. Such as
Turing:

put "word":10, "another"

where you spesify a minimum length. Very good for formating output.

Real variables have a second flag.
Turing:

var num:real := 1*2*3*4*5*6*7*8*9*10
put num
put num:0:1

where 2nd :number forces that amount of decimal points.
Jay




PostPosted: Fri Mar 04, 2005 9:55 am   Post subject: (No subject)

Thanks very much, that helps a lot.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: