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.

Recommended Answers

All 4 Replies

One option is something like:

float in = 131.14567f;
  int left = (int)in;
  float right = left - in;

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.