You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Fuad Efendi <fu...@efendi.ca> on 2007/02/04 21:25:18 UTC

Float Values shown as 1.2E7

Hello,

http://www.tokenizer.org shows price (in CAD$) 1.2E7 instead of 11999999.99
(that is real!)

I use "sfloat" for a price field... 
If you see different page, click 'refresh' F5; HTTP Caching...

Thanks,
Fuad


RE: Float Values shown as 1.2E7

Posted by Fuad Efendi <fu...@efendi.ca>.
I changed and reindexed... It still shows <double
name="dprice">1.2E7</double> instead of 11,999,999.99

-----Original Message-----
From: Yonik Seeley 

On 2/4/07, Fuad Efendi <fu...@efendi.ca> wrote:
> >Try an sdouble if you need exact prices that large.
>
> Thanks,
> Will it broke my indexes if I modify schema.xml and restart Tomcat?

Yes, float isn't compatible with double since they are essentially
stored in a modified IEEE format.  You will need to re-index.

-Yonik



Re: Float Values shown as 1.2E7

Posted by Yonik Seeley <yo...@apache.org>.
On 2/4/07, Fuad Efendi <fu...@efendi.ca> wrote:
> >Try an sdouble if you need exact prices that large.
>
> Thanks,
> Will it broke my indexes if I modify schema.xml and restart Tomcat?

Yes, float isn't compatible with double since they are essentially
stored in a modified IEEE format.  You will need to re-index.

-Yonik

RE: Float Values shown as 1.2E7

Posted by Fuad Efendi <fu...@efendi.ca>.
>Try an sdouble if you need exact prices that large.

Thanks,
Will it broke my indexes if I modify schema.xml and restart Tomcat?


RE: Float Values shown as 1.2E7

Posted by Chris Hostetter <ho...@fucit.org>.
: Are we using DecimalFormat class somewhere?

I had to check, when using the XML output at least, a simple
Double.toString(val) is used...

: 1.199999999E7
:
: I post (ASCII string) value 1.2E7 via XML POST, of course SOLR should return
: 1.2E7; I'll try to post 11999999.99, let's see... Field is defined as
: sdouble now...

while it may not be ideal for display, 1.199999999E7 == 11999999.99,
there's no loss of precission there.


-Hoss


RE: Float Values shown as 1.2E7

Posted by Fuad Efendi <fu...@efendi.ca>.
Are we using DecimalFormat class somewhere?

I just tested, even Double.toString() returns something not-acceptable for
front-end application:

1.199999999E7

I post (ASCII string) value 1.2E7 via XML POST, of course SOLR should return
1.2E7; I'll try to post 11999999.99, let's see... Field is defined as
sdouble now...



-----Original Message-----
From: Yonik Seeley [mailto:yonik@apache.org] 
Sent: Sunday, February 04, 2007 3:44 PM
To: solr-dev@lucene.apache.org
Subject: Re: Float Values shown as 1.2E7


On 2/4/07, Fuad Efendi <fu...@efendi.ca> wrote:
> Hello,
>
> http://www.tokenizer.org shows price (in CAD$) 1.2E7 instead of
11999999.99
> (that is real!)
>
> I use "sfloat" for a price field...

An IEEE float only has 24 mantissa bits (7 decimal digits) of precision.
24*log(2)/log(10) = 7.22

Try an sdouble if you need exact prices that large.

-Yonik



Re: Float Values shown as 1.2E7

Posted by Yonik Seeley <yo...@apache.org>.
On 2/4/07, Fuad Efendi <fu...@efendi.ca> wrote:
> Hello,
>
> http://www.tokenizer.org shows price (in CAD$) 1.2E7 instead of 11999999.99
> (that is real!)
>
> I use "sfloat" for a price field...

An IEEE float only has 24 mantissa bits (7 decimal digits) of precision.
24*log(2)/log(10) = 7.22

Try an sdouble if you need exact prices that large.

-Yonik