440,171 Members | 776 Online
Need help? Post your question and get tips & solutions from a community of 440,171 IT Pros & Developers. It's quick & easy.

# Getting fractional part from a float without using string operations

 P: n/a Thanks, Srini Add more friends to your messenger and enjoy!Go to http://messenger.yahoo.com/invite/ Nov 19 '08 #1
4 Replies

 P: n/a On Nov 20, 12:35*am, srinivasan srinivas wrote: | >>import math | >>num = 123.4567 | >>math.modf(num) | (0.45669999999999789, 123.0) Nov 19 '08 #2

 P: n/a On Nov 19, 1:44*pm, John Machin wrote: | >>import math | >>num = 123.4567 | >>math.modf(num) | (0.45669999999999789, 123.0) def frac(n): return n - int(n) Nov 19 '08 #3

 P: n/a "MRAB" wrote: | >>import math | >>num = 123.4567 | >>math.modf(num) | (0.45669999999999789, 123.0) def frac(n): return n - int(n) n % 1.0 Nov 19 '08 #4

 P: n/a On Nov 20, 3:38*am, "Blind Anagram" wrote: | >>import math | >>num = 123.4567 | >>math.modf(num) | (0.45669999999999789, 123.0) def frac(n): * * return n - int(n) n % 1.0 | >>n= -123.4567 | >>n % 1.0 | 0.54330000000000211 Nov 19 '08 #5

### This discussion thread is closed

Replies have been disabled for this discussion.