Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Time
Message
De
01/11/2001 20:16:28
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
01/11/2001 20:04:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Time
Divers
Thread ID:
00575377
Message ID:
00576534
Vues:
24
More about modulus:

  • The "%" operator is the same as the "mod()" function.
  • It also works on fractional numbers: great for dividing a currency (money) value into available coins.
  • Please note that, as in my example, it is quite possible to arrive at the same result without modulus (I showed alternatives with and without modulus).

    Hilmar.

    >>The other replies basically answered your question, but perhaps you want to know how to solve the math involved, since it can be used in a variety of situations (for instance, converting a monetary amount into available bills/coins).
    >>
    >>
    >>TotalSeconds = 72600
    >>Hours = int(TotalSeconds / 3600)
    >>SecondsLeft = TotalSeconds - lnHours * 3600
    >>* or: SecondsLeft = TotalSeconds % 3600
    >>Minutes = int(SecondsLeft / 60)
    >>Seconds = SecondsLeft - 60 * Minutes && or SecondsLeft % 60
    >>
    >>* Output may be something like this:
    >>? padl(Hours, 2, "0") + ":" + padl(Minutes, 2, "0") + ":" + padl(Seconds, 2, "0")
    >>
    >>
    >>Hilmar.
    >
    >Thanks Hilmar,
    >
    >It was the modulus function that kept me from arriving at the destination. I was suffering from math block.
    Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
  • Précédent
    Répondre
    Fil
    Voir

    Click here to load this message in the networking platform