Splitting a double!!

Hi all,I have I question and I need to hear ideas from Java programmers.If I have a double in the form of aabb.ccc and I want to save the aa in a double and bb.ccc in another double how can I achieve this?!waiting to hear the ideas
[298 byte] By [Computer_Engineera] at [2007-11-27 6:11:15]
# 1
well, you can convert to a string, take some substrings, then convert back. But I'm not sure what the purpose is. The aa part as a double would be 2 decimal places out of range at that point...
bsampieria at 2007-7-12 17:17:26 > top of Java-index,Java Essentials,Java Programming...
# 2
It depends. Are there always going to be four digits before the decimal? If so, you can do this.double aa = yourDouble / 100;double bbccc = yourDouble % 100;
CaptainMorgan08a at 2007-7-12 17:17:26 > top of Java-index,Java Essentials,Java Programming...
# 3

> It depends. Are there always going to be four digits

> before the decimal? If so, you can do this.

> double aa = yourDouble / 100;

> double bbccc = yourDouble % 100;

Thats a pretty clever solution. Won't double add a load more number on the end like 1234324 though?

_helloWorld_a at 2007-7-12 17:17:26 > top of Java-index,Java Essentials,Java Programming...
# 4

> Thats a pretty clever solution. Won't double add a

> load more number on the end like 1234324 though?

I have the same fear. Would it make sense to multiply first by 1000 convert to an int, and then do the divide and mod:

double yourDouble = aabb.ccc;

int myInt = (int)(1000 * yourDouble);

int aa = myInt / 100000;

int bbccc = myInt % 100000;

or what about just using decimals?

Message was edited by:

petes1234

petes1234a at 2007-7-12 17:17:26 > top of Java-index,Java Essentials,Java Programming...
# 5
Thanks All for the ideas :)
Computer_Engineera at 2007-7-12 17:17:26 > top of Java-index,Java Essentials,Java Programming...