Issue 59335 - BATHTEXT() function is wrong when value is more than 1000000
Summary: BATHTEXT() function is wrong when value is more than 1000000
Status: CLOSED FIXED
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: OOo 2.0.1
Hardware: PC Windows XP
: P3 Trivial (vote)
Target Milestone: ---
Assignee: oc
QA Contact: issues@sc
URL:
Keywords:
Depends on:
Blocks: 41707 60011
  Show dependency tree
 
Reported: 2005-12-14 12:08 UTC by pocha
Modified: 2013-08-07 15:13 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Bathtext (19.41 KB, application/vnd.sun.xml.calc)
2005-12-14 12:16 UTC, pocha
no flags Details
Patch relative to dr's patch (739 bytes, patch)
2006-01-04 05:00 UTC, jjc
no flags Details | Diff
Patch relative to 2.0.1 (953 bytes, patch)
2006-01-04 05:01 UTC, jjc
no flags Details | Diff
Test document (33.50 KB, application/vnd.ms-excel)
2006-01-06 14:31 UTC, daniel.rentz
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description pocha 2005-12-14 12:08:36 UTC
=bathtext(1000001) will be displayed หนี่งล้านบาทถ้วน (one million bath).
=bathtext(1000002) will be displayed หนึ่งสองล้านบาทถ้วน (one two million bath).
I test value less than 1000000 and they seem to be OK.
If I test value more than 1000000 then they seem to be wrong.
Comment 1 pocha 2005-12-14 12:16:13 UTC
Created attachment 32380 [details]
Bathtext
Comment 2 frank 2005-12-14 12:44:26 UTC
Hi Daniel,

seems to be yours.

Frank
Comment 3 daniel.rentz 2005-12-14 13:17:43 UTC
fixed in src680/dr43 (OOo 2.0.2)
Comment 4 jjc 2006-01-04 04:58:36 UTC
The fix only fixes half the problem (the misplacement of the "million" word). 
There's still an off-by-one problem.  BAHTTEXT(1000001) gives the same result as
BAHTTEXT(1000000); in general for n > 1000000, BAHTTEXT(n) is giving a string
representation of n - 1.

It's a rounding problem in the code. For example, for the case of 10000001,  
the existing code does in effect

   floor((1000001.0/1000000.0 - 1.0)*1000000.0)

which gives a value of 0 rather than 1, because 1000001.0/1000000.0 gives a
value very slightly less than 1.000001.
Comment 5 jjc 2006-01-04 05:00:08 UTC
Created attachment 32884 [details]
Patch relative to dr's patch
Comment 6 jjc 2006-01-04 05:01:36 UTC
Created attachment 32885 [details]
Patch relative to 2.0.1
Comment 7 daniel.rentz 2006-01-04 12:04:23 UTC
indeed, sigh...
Comment 8 daniel.rentz 2006-01-04 16:51:38 UTC
fixed again
Comment 9 daniel.rentz 2006-01-06 14:31:51 UTC
Created attachment 32965 [details]
Test document
Comment 10 daniel.rentz 2006-01-06 14:33:19 UTC
back to QA

Please use the attached document i59335_bahttext.xls to verify this issue.
Comment 11 daniel.rentz 2006-01-06 14:34:00 UTC
set owner
Comment 12 daniel.rentz 2006-01-06 14:36:52 UTC
fixed
Comment 13 oc 2006-01-11 14:09:34 UTC
verified in internal build cws_dr43
Comment 14 oc 2006-02-13 14:08:51 UTC
closed because fix available in OOo2.0.2m156