posted 12 years ago

Hello all,

Thank you for taking the time to read my post

I was wondering if any of you might have come across something like this

before.

I'm trying to add key value pairs into a SortedMap, where the key is a

Double.

The key is usually a number like 0.01042 which has 6 digit precision.

SortedMap newMap = new TreeMap();

newMap.put(key, value);

The problem is that when I try to do something like

Object key = newMap.getFirstKey();

Double keyDouble = Double.getValue(key);

double timeStamp1 = firstKey.doubleValue();

the timeStamp1 value when printed out is only 1 decimal place precision

(0.0).

Can anyone suggest anything please ? Thanks in advance for any suggestions.

Trish.

Thank you for taking the time to read my post

I was wondering if any of you might have come across something like this

before.

I'm trying to add key value pairs into a SortedMap, where the key is a

Double.

The key is usually a number like 0.01042 which has 6 digit precision.

SortedMap newMap = new TreeMap();

newMap.put(key, value);

The problem is that when I try to do something like

Object key = newMap.getFirstKey();

Double keyDouble = Double.getValue(key);

double timeStamp1 = firstKey.doubleValue();

the timeStamp1 value when printed out is only 1 decimal place precision

(0.0).

Can anyone suggest anything please ? Thanks in advance for any suggestions.

Trish.

Trish Hartnett

Greenhorn

Posts: 18

posted 12 years ago

hello,

thank you both for replying.

Sorry about the line saying "Double keyDouble = Double.getValue(key);" - that was me getting muddled with something.

What I'm trying to do is:

Double firstKey = (Double)firstRow.firstKey();

double timeStamp1 = firstKey.doubleValue();

Double secondKey = (Double)secondRow.firstKey();

double timeStamp2 = secondKey.doubleValue();

double interval = timeStamp1 - timeStamp2;

where firstRow and secondRow are 2 separate TreeMaps. Each TreeMap contains a timestamp (key) and a number(value). I want to subtract the timestamps to see if there is a particular interval between them. The problem is that the timestamps should be something like 376222.010420 and 37622.020837 (0.010420 apart).

Thanks again, any suggestions gratefully received.

Trish.

thank you both for replying.

Sorry about the line saying "Double keyDouble = Double.getValue(key);" - that was me getting muddled with something.

What I'm trying to do is:

Double firstKey = (Double)firstRow.firstKey();

double timeStamp1 = firstKey.doubleValue();

Double secondKey = (Double)secondRow.firstKey();

double timeStamp2 = secondKey.doubleValue();

double interval = timeStamp1 - timeStamp2;

where firstRow and secondRow are 2 separate TreeMaps. Each TreeMap contains a timestamp (key) and a number(value). I want to subtract the timestamps to see if there is a particular interval between them. The problem is that the timestamps should be something like 376222.010420 and 37622.020837 (0.010420 apart).

Thanks again, any suggestions gratefully received.

Trish.