Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
rounding numbers in GUI.
Author Message
Bruski

Posted: Mon Jun 16, 2003 7:21 am   Post subject: rounding numbers in GUI.

anyone know how to round the numbers to two decimal places....usually its :6:2 second being the amount of decimal places to display but im new to the GUI. commands and got no clue as to where to put this...any suggestions

thx again

Andy

Posted: Mon Jun 16, 2003 9:27 am   Post subject: (No subject)

just round it ur self, multiply the number by 100, div it by 1 and then / it by 100
Homer_simpson

Posted: Mon Jun 16, 2003 11:19 am   Post subject: (No subject)

use my function to turn them into what you want
 code: function decimal (r : real, i : int) : real     var rs := realstr (r, 1)     var ts := ""     var c := 1     var c2 := 0     var dec := false     loop         if rs (c) not= "." then             ts += rs (c)         else             ts += "."             dec := true         end if         exit when c = length (rs) or c2 = i         c += 1         if dec then             c2 += 1         end if     end loop     result strreal (ts) end decimal put decimal (32.231321, 2)
Bruski

Posted: Mon Jun 16, 2003 11:50 am   Post subject: (No subject)

im confused...where do i put that...?
Homer_simpson

Posted: Mon Jun 16, 2003 1:04 pm   Post subject: (No subject)

put
 code: function decimal (r : real, i : int) : real     var rs := realstr (r, 1)     var ts := ""     var c := 1     var c2 := 0     var dec := false     loop         if rs (c) not= "." then             ts += rs (c)         else             ts += "."             dec := true         end if         exit when c = length (rs) or c2 = i         c += 1         if dec then             c2 += 1         end if     end loop     result strreal (ts) end decimal

at the top of your program...
this is how the functionworks

decimal(num:real,dec:int)

num is the number that you want to round
and dec is the number of decimals you want it to have

so if you put:
put deimal(100.5555,1)
the out put will be 100.5
JayLo

Posted: Mon Jun 16, 2003 1:41 pm   Post subject: (No subject)

wait... i used frealstr to do something like this... i'll try and find an example.
Andy

Posted: Mon Jun 16, 2003 2:26 pm   Post subject: (No subject)

there is such an command? what does it do? too lazy to go to turing and type and press F9
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 7 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: