Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

help for numeric to fractions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • help for numeric to fractions

    im just exploring :D

    is there any functions that numeric format will convert to fractions?
    any help pls.


    sincerely,

    nehru l. albania
    philippines
    "Knowledge without application is useless."

  • #2
    Re: help for numeric to fractions

    Originally posted by nehru View Post
    im just exploring :D

    is there any functions that numeric format will convert to fractions?
    any help pls.


    sincerely,

    nehru l. albania
    philippines
    Check this thread.
    There can be only one.

    Comment


    • #3
      Re: help for numeric to fractions

      A simpler expression and a more elegant display:

      Code:
      int(x)+chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1))
      As in:
      Code:
      x=3.25
      ?int(x)+chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1))
      = "3"
      
      x=3.5
      ?int(x)+chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1))
      = "3"
      
      x=3.75
      ?int(x)+chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1))
      = "3"
      Last edited by G Gabriel; 09-07-2007, 09:54 AM.

      Comment


      • #4
        Re: help for numeric to fractions

        Nice, Gabe, but your expression does not take care of cases where the fraction is less than 0.25.

        Code:
        x=3.12
        ?int(x)+chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1))
        = "3"
        
        x=3.42
        ?int(x)+chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1))
        = "3"

        To expand on your expression, you could use:
        Code:
        x=3.12
        ?int(x)+if(mod(x,1)<.25,"",chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1)))
        = "3"
        
        x=3.42
        ?int(x)+if(mod(x,1)<.25,"",chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1)))
        = "3"
        Steve

        Comment


        • #5
          Re: help for numeric to fractions

          x=3.42
          ?int(x)+if(mod(x,1)<.25,"",chr(-66+case(mod(x,1)<.5,-2,mod(x,1)<.75,-1)))
          = "3"
          That would be true if he wants to round down to nearest quarter. Don't know if that's the intention.

          I just put the elemintary stuff, but I am not sure how far he wants to take this. How about 1/8 or 3/8 or 5/8 or 1/16 etc..
          To my knowledge, there is no ASCII for those and you have to contend with the clumpsy looking fractions if you have to.

          Edit my original expression to:
          Code:
          int(x)+chr(-68+case(mod(x,1)<.25,68,mod(x,1)<.5,0,mod(x,1)<.75,1,mod(x,1)<1,2))
          Last edited by G Gabriel; 09-07-2007, 10:12 AM.

          Comment


          • #6
            Re: help for numeric to fractions

            Super simplified:
            Code:
            int(x)+chr(-69+if(mod(x,1)=0,69,mod(x,1)/.25))

            Comment


            • #7
              Re: help for numeric to fractions

              Originally posted by G Gabriel View Post
              That would be true if he wants to round down to nearest quarter. Don't know if that's the intention.
              Your expression was rounding down to the nearest quarter for amounts with fractions above 0.25. I was just being consistent.

              Also, your lastest expression doesn't work:
              Code:
              x=3.89
              ?int(x)+chr(-69+if(mod(x,1)=0,69,mod(x,1)/.25))
              = "3"
              The bottom line is that to round to quarters (whether up or down) you must test for four cases. Your expressions only test for three cases. The case of an integer alone (followed by no fraction) must be allowed whether you are rounding up or down.

              Steve
              Last edited by Steve Andrews; 09-07-2007, 11:27 AM.

              Comment


              • #8
                Re: help for numeric to fractions

                Steve:
                This code:
                int(x)+chr(-69+if(mod(x,1)=0,69,mod(x,1)/.25))

                is only intended for quarters.

                I see you are passionate about other fractions and rounding. I don't know if that's the intent of the question. I am limiting my response only to those fractions that are available in ASCII and nothing else and those are quarter, half and three quarters, Only

                Stan referrenced another thread that dealt with just that, quarters. After reading that thread, I added:
                A simpler expression and a more elegant display:
                It is more elegant as those fractions are available as ASCII characters so you don't have to use 1/4 or 1/2 and 3/4 but rather , and

                I am only talking about QUARTERS and offering an alternative to the solutions offered in the other thread that I thought would be simpler and more elegant!

                I am not about to branch out into speculations of what other fractions and which way to round, up or down.
                Last edited by G Gabriel; 09-07-2007, 12:58 PM.

                Comment


                • #9
                  Re: help for numeric to fractions

                  Actually I referenced a thread which started out asking about fractions but wasn't clear that only quarters would be necessary. I wound up doing some work on reducing fractions in general but never pursued testing it.

                  Code:
                  function NumberFract as C(numbvalue as n) 
                  dec = (numbvalue-(int(numbvalue)))*10000
                  fnum = dec
                  f2num = 10000
                  for i = 10000 to 1 step -1
                  
                  if mod(fnum,i)=0 .and. mod(f2num,i) = 0
                  fnum = dec/i
                  f2num =10000/i
                  exit for
                  end if
                  next i
                  
                  for i = 10 to 2 step -1
                  reduce:
                  if mod(int(fnum),i) = 0 .and. mod(int(f2num),i) = 0
                  fnum = fnum/i
                  f2num = f2num/i
                  goto reduce
                  end if
                  next i
                  	
                  
                  NumberFract=alltrim(str(int(numbvalue),255,0))+" "+ alltrim(if(mod(dec,10000)=0,""," "+ alltrim(str(fnum,255,0))+"/"+alltrim(str(f2num))) )
                  
                  end function
                  There can be only one.

                  Comment


                  • #10
                    Re: help for numeric to fractions

                    wow....you guys really great....

                    thank you to all of you

                    god bless

                    sincerely,

                    nehru l. albania
                    philippines
                    "Knowledge without application is useless."

                    Comment


                    • #11
                      Re: help for numeric to fractions

                      OK...I am going to try one more time:
                      To my knoweldge, there are no other fractions in ASCII except for 1/4, 1/2 and 3/4.

                      So, if you are dealing with those fractions and want an expression that takes advantage of those ASCII characters so as to have that elegant display, this is what my expression is for.

                      For any other fractions, i.e. 1/8, 1/16, or 324569873/67398769155667, I am afraid, you have to use the clumpsy display.

                      Comment


                      • #12
                        Re: help for numeric to fractions

                        Originally posted by G Gabriel View Post
                        Steve:
                        This code:
                        int(x)+chr(-69+if(mod(x,1)=0,69,mod(x,1)/.25))

                        is only intended for quarters.
                        I know that your expression was only intended for quarters. But it doesn't work for quarters as I showed with the case where x=3.89. Your expression returns "3" for that value of x. Thus, your expression is invalid ... unless you think that "3" is 3.89 rounded to a nearest quarter (up or down).

                        Comment


                        • #13
                          Re: help for numeric to fractions

                          Originally posted by G Gabriel View Post
                          OK...I am going to try one more time:
                          To my knoweldge, there are no other fractions in ASCII except for 1/4, 1/2 and 3/4.
                          True, so if you want an expression for rounding to a quarter you must allow for each of those three ASCII codes OR no fraction at all. Upon rounding down, "3.12" must return "3" without any fraction. Upon rounding up, "4.89" must return "5".

                          Some of your expressions return such values as "3", "3", "3", "4", "4", etc. they should allow for "3", "3", "3", "3", "4", "4", "4", etc.

                          Comment


                          • #14
                            Re: help for numeric to fractions

                            If somebody wants to venture in the academics and say, OK, what if the fraction is 234/567, how do I display it as a fraction and not decimal?

                            That's the type of question that makes absolutely no sense.

                            Why?

                            Because, how do you get a fraction like that in alpha?
                            Only way you could have a fraction like that is if you actually entered it as such in a character field. If you enter such fraction in a numeric field, it will display as decimal.

                            So, let's say that you did enter a fraction like this in a numeric field and you want it displayed as such and not as decimal, how do you do that?

                            That would yet be another dumb question:
                            because, if somebody enters 234/567 in a numeric field, it will display as:
                            0.41

                            If you ask how to convert 0.41 back to 234/567 that would be the ultimate dumb question, because 0.41 could be 41/100 or it could be 234/567. You cannot possibly know what it was.

                            So, what would be the answer to the original dumb question of how do I enter it as 234/567 and display it as such?
                            Just enter it as such in a character field. That's why the question would be dumb. And when I read a thread like this, I make a reasonable assumption that people who work with alpha aren't that dumb to be asking such questions.

                            I could see somebody replying: maybe you would get a fraction like this in alpha if you import it from some other program.

                            Not so. If you import it as numeric, it will be decimal. If you import it as character, now you have the display you wanted in the first place and there would be no need to ask.

                            Sometimes, or hopefully most of the times, when responding to questions on the board, the common sense of your sub-conscious takes over, and it's a good thing. Let it.
                            Last edited by G Gabriel; 09-07-2007, 02:22 PM.

                            Comment


                            • #15
                              Re: help for numeric to fractions

                              Steve:
                              Some of your expressions return such values as "3", "3", "3", "4", "4", etc. they should allow for "3", "3", "3", "3", "4", "4", "4", etc.
                              Not sure what you are talking about. The expression produces the correct results:
                              Code:
                              x=3
                              ?int(x)+chr(-69+if(mod(x,1)=0,69,mod(x,1)/.25))
                              = "3"
                              x=3.25
                              ?int(x)+chr(-69+if(mod(x,1)=0,69,mod(x,1)/.25))
                              = "3"
                              x=3.5
                              ?int(x)+chr(-69+if(mod(x,1)=0,69,mod(x,1)/.25))
                              = "3"
                              x=3.75
                              ?int(x)+chr(-69+if(mod(x,1)=0,69,mod(x,1)/.25))
                              = "3"
                              so if you want an expression for rounding
                              I am not talking about any rounding. How did you assume that the questioner wanted to round? and whether he wanted to round up or down?
                              For Pete's sake, I am talking about .25, .5, and .75 ONLY. That's how the other thread at least how it started. I was only offering a better alternative.
                              Last edited by G Gabriel; 09-07-2007, 01:29 PM.

                              Comment

                              Working...
                              X