Author Topic: Returning the fraction / decimal / remainder part of a number  (Read 2519 times)

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
I'm contributing this here because even though it's really simple, I was surprised there was no command to return it directly.

If you have a number (eg. 63.45) and want to return the ".45" part only it's as simple as
Code: (glbasic) [Select]
FUNCTION FractionOnly : Number
Return (Number - INTEGER(Number))


Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3375
  • Integrated Brain
    • View Profile
Hi Future thanks for this simple but I think usefully code...  :good:

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10815
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
fmod(number, 1.0)