Algorithms

Moderators: None (Apply to moderate this forum)
Number of threads: 384
Number of posts: 762

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Re: I need your help with numerical treatment Posted by Josh Code on 22 Aug 2002 at 7:52 PM
: Hi,
:
: Im begginning and find a problem. I need to show fractions in my program to the user not as a real number. How should I define these variables ? Is there any algorithm that converts from real to rational numbers ? Or any way to showing it in the X/Y format to the user ?
:
:

Yes you can sort of convert to a rational number from a real. The routines for this depend on the language you are programming with. The routines are usually called "round" or "rnd". What you call rational numbers are the type "integer" or "int". The round routines just round a real number to an integer.

You can also output something like x/y. You need to convert the real values to strings(a textual type that stores a bunch of letters or characters in a "string"). You can just add stings together like this:
xasString + "/" + yAsString. Again, some things like the quote signs may be different for a different language. All you would have to do after that is draw that string on the screen or put it in a component.


Thread Tree
Thiago I need your help with numerical treatment on 18 Aug 2002 at 7:26 PM
Josh Code Re: I need your help with numerical treatment on 22 Aug 2002 at 7:52 PM
Thiago Re: I need your help with numerical treatment on 26 Aug 2002 at 7:12 PM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.