Author Topic: The question of money  (Read 1063 times)

0 Members and 1 Guest are viewing this topic.


  • Knight at Arms
  • *
    • View Profile
  • Faction: Neutral
The question of money
« on: June 04, 2014, 06:17:12 AM »
Good afternoon. Question to the developers. Tell me how you did the division of money into dollars and cents? Where and in a module system that you prescribed for this?
Человек — это только промежуточное звено, необходимое природе для создания венца творения: рюмки коньяка с ломтиком лимона. «Понедельник начинается в субботу». Братья Стругацкие.


  • Moderator
  • *
  • Seize Him!
    • View Profile
  • Faction: Bandit
  • WB
Re: The question of money
« Reply #1 on: June 12, 2014, 03:15:01 AM »
I forget the specifics now, but you just have to create a helper function that splits each dollar amount into dollars and cents, and returns each in a separate variable.  Stick the values into whatever variables you need to get them out.

dollars = TRUNCATE(total amount /100)
cents = total amount %(modulus) 100

Create another function to format those values into a string, so it will be "X dollars and Y cents", but so that it will work when either value is 0.  And create another function to display those values in the $X.YY format.

Done.  But then the hardest part by far is substituting every occurance of "denars" in the module system.  Good luck!