Which works only if fullDouble < 2^31.  Given that a double is 64 bits, 
I'd use a long rather than an int.  That will work for all doubles that 
can exactly represent an integer (< 2^52).

=Spencer

Conway. Fintan (IT Solutions) wrote:

>How about :
>
>public double[] myModf(double fullDouble) {
>       int intVal = (int)fullDouble;
>       double remainder = fullDouble - intVal;
>
>       double[] retVal = new double[2];
>       retVal[0] = intVal;
>       retVal[1] = remainder;
>
>       return retVal;
>}
>
>HTH,
>
>Fintan
>       
>
>  
>
>>-----Original Message-----
>>From: Jeff Fisher [SMTP:[EMAIL PROTECTED]]
>>Sent: 04 September 2002 13:02
>>To:   JDJList
>>Subject:      [jdjlist] modf in in java
>>
>>Does java have anything like the modf c function?  I checked the math
>>class,
>>but there is just ciel and floor.  I can get the first part of the double
>>value by casting as to an int, but the fractional part is not so easy.  I
>>can get it as a double, but I'd like it as an integer.
>>
>>So what I'm trying to do here is split the number 123.45 into 123 and 45.
>>
>>Any thoughts?
>>
>>Thanks
>>
>>Jeff
>>
>>To change your JDJList options, please visit:
>>http://www.sys-con.com/java/list.cfm
>>    
>>
>
>
>* ** *** ** * ** *** ** * ** *** ** *
>This email and any files transmitted with it are confidential and
>intended solely for the use of the individual or entity to whom they
>are addressed. 
>Any views or opinions presented are solely those of the author, and do not necessarily
>represent those of ESB. 
>If you have received this email in error please notify the sender.
>
>Although ESB scans e-mail and attachments for viruses, it does not guarantee
>that either are virus-free and accepts no liability for any damage sustained
>as a result of viruses.
>
>* ** *** ** * ** *** ** * ** *** ** *
>
>To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm
>  
>



To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to