954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

seperating a decimal

How would one seperate a decimal into 2 numbers, the left and right sides of the decimal?

float example = 131.14567

into...

int left = 131
float right = .14567

thanks.

Nemoticchigga
Junior Poster in Training
98 posts since Feb 2008
Reputation Points: 10
Solved Threads: 2
 
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

One option is something like:

float in = 131.14567f;
  int left = (int)in;
  float right = left - in;
Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

Or may be convert the double into string. Then split the string using "." as the delimiter??

raul15791
Junior Poster
102 posts since Jun 2008
Reputation Points: 37
Solved Threads: 7
 

Stop indulge in fantasies. See iamthwee's exhaustive answer...

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You