INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

UBasic Modulo Function Update

UBasic Modulo Function Update

(OP)
With regards to thread204-1706016: UBasic Modulo Function

Quote (JHHPavel)

I was writing a program in UBasic, ... and couldn't remember the proper format for the modulo function.

I tried googling for help but ... I couldn't find a math function help screen.

Does anyone know the proper format? Or have a link to a UBasic help site that doesn't deal with focusing cameras?

Found a site that may help -- even though it's a 2-year old post, this may be of use for the next person. It mentions cameras towards the later half of the wiki.

http://chdk.wikia.com/wiki/UBASIC/TutorialScratchp...

Once there, search for the section entitled (now get this...)

Math Expressions allowed in uBASIC

It is approximately 1/4 of the way down from the top (currently). I'd recommend you use your browser's "FIND" function for the above (or at least 'Math Expressions').

Then carefully read the first 2 paragraphs.


AND Before anyone gets mad; there is no uBASIC on this site. Not like it's still active nor popular, BUT I've checked and we have:

  • DarkBASIC
  • Visual BASIC
  • Visual BASIC for Applications (VBA)
  • QBasic
  • Even, Vb Script
So I think this was the only choice forum to post that question. And (at least for me) warranted some help.

--MiggyD

RE: UBasic Modulo Function Update

(OP)
In case the wiki is gone, I'd thought I'd follow up....

In short MODULO (in UBasic) simply means "REMAINDER" -- and -- the mathematical expression to activate it is by using the percent sign (%).

Quote (FROM The Wiki Page)


Most of the expressions are easy to understand, but the % (remainder) operation might like a short explanation.

Example: Let's say you have computed a number to equal how many seconds something will take for a duration. Such as s=(some math expression) Where s is being assigned the number of seconds computed.
In math it's called "modulo".

Now you want to display that as minutes and seconds. You will need a print statement such as:

print "Total Time:" , s/60; "min", (the remainder of s/60); "sec"

There is a very simple way to do this using the % command. Think of % as "the remainder of s being divided by". So all you need to do is have this print statement:

print "Total Time:" , s/60; "min", s%60; "sec"

If s had the value of 328 seconds, then this would print out to

Total Time: 5 min 28 sec
--OR--
Total Time: (328/60)=5 min (the remainder of 328/60)=28 sec



So based on that info, if someone gave you (US) 459 pennies you could use modulo to tell you that a customer gave you 4 dollars and 59 cents with:

print " whole dollars:", 459/100
print "additional cents:", 459%100

In this example, 1 U.S. dollar (the WHOLE unit) is made up of 100 pennies.
In the wiki example, 1 minute (the WHOLE unit) is made up of 60 seconds.

Modulo may be appropriate in certain calculations. One would just need to know the Whole Unit and it's constituents.

    Kitchen...
      1 fluid cup = 8 fluid ounces // 1 quart = 4 cups = 32 ounces

      Medical...
      1 cc = 1 mL // 1 tsp = 5 cc // 1 Tbsp = 3 tsp = 15 cc (or 15 mL)
      1 fluid ounce = 2 Tbsp = 30 cc (or 30 mL)

      (etc)
 

HTH
--MiggyD

After pondering the riddle (for many years I might add) I finally got the answer (inadvertently through a movie): "If a tree falls in the forest and no one is around, does it make a sound?"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close