Advertisement

09.01.2006 at 10:43AM PDT, ID: 21975652
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Need help with rounding decimal to fraction formula

Asked by QTony in Crystal Reports Software

Tags: , , , ,

I am a new user to Crystal (6 months) and I use it to create reports for a cabinet making program called CabinetVision. I recently have been struggling with what should be a simple task which is to convert a decimal generated number into a fraction.

With the help of this forum (myself 10% the forum 90%) I've gotten a decimal to fraction conversion formula up and running---sort of.

The problem is that it is not rounding properly.  The program I am using (see above)  is generating decimals numbers that  round themselves to the closest 1/16

Ex: 1/16 = .0625 or
Ex: 1/8 = .1250

The decimal to fraction conversion formula is not something I prepared; I  downloaded it from Business Objects' knowledge base.

Here are the fractions I want to generate side by side with the actual fractions generated by the conversion formula:

What I want                    What I'm getting

        0                                       0/2  (?)

      1/16                                    3/50

      1/8                                    13/100

      3/16                                  19/100

      1/4                                      1/4

      5/16                                   31/100

      3/8                                     19/50

      7/16                                   11/25

      1/2                                       1/2


and so on


I feel like I'm so close; This is a very important formula for me to get running, any and all help is always appreciated---Thanks

Here is the formula:  Note: {@DECIMAL} is my internal formula that generates the decimal number that needs to be converted          
                                        into a fraction


_____________________________________________________________________________________________________
   
                                       
' This formula uses Basic syntax.

'Note: {@DECIMAL} is my internal formula that generates the decimal number that needs to be converted  into a fraction

     

Evaluateafter ({@DECIMAL})  

Dim decInput as number

Dim decimalFraction as number

Dim numerator as number

Dim denominator as number

Dim wholeNumber as number

' This variable will hold the value to be converted

' to a fraction type value.

Dim testNum as number

' The number 1.75 will be converted to look like

' 1 3/4 as a string output.

testNum = {@DECIMAL}

wholeNumber = int(testNum)

' In CR 8.5 this line would be

' decInput = round(testNum - wholeNumber,2)

decInput = round(testNum - wholeNumber,2)

numerator = 1

denominator = 1

decimalFraction = numerator / denominator

do While (decimalFraction <> decInput)

If (decimalFraction < decInput) Then

numerator = numerator + 1

Else

denominator = denominator + 1

numerator = truncate(decInput * denominator)

End If

decimalFraction = numerator / denominator

loop

formula = totext(wholeNumber,0,"") + " " + totext(numerator,0 , "") & "/" & totext(denominator,0 , "")



     

 Start Free Trial
[+][-]09.01.2006 at 11:00AM PDT, ID: 17438755

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.01.2006 at 11:10AM PDT, ID: 17438814

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.01.2006 at 11:22AM PDT, ID: 17438901

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.01.2006 at 11:25AM PDT, ID: 17438921

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.01.2006 at 11:33AM PDT, ID: 17438974

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.01.2006 at 11:40AM PDT, ID: 17439038

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Crystal Reports Software
Tags: decimal, crystal, fraction, formula, rounding
Sign Up Now!
Solution Provided By: frodoman
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09.01.2006 at 12:07PM PDT, ID: 17439194

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.01.2006 at 12:22PM PDT, ID: 17439278

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.01.2006 at 03:11PM PDT, ID: 17440213

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.01.2006 at 03:54PM PDT, ID: 17440386

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.01.2006 at 04:47PM PDT, ID: 17440568

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.01.2006 at 04:58PM PDT, ID: 17440598

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32