Bug 141078 - INT fonction seems wrong in some cases
Summary: INT fonction seems wrong in some cases
Status: RESOLVED DUPLICATE of bug 63242
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.4.7.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-17 12:29 UTC by Sebastien COGEZ
Modified: 2022-12-28 11:24 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastien COGEZ 2021-03-17 12:29:25 UTC
Description:
I try to generate random numbers and I need to evaluate a small decimal part of my numbers.
I do a int((A1-int(A1))*60) on random numbers with one digit
But in some cases, when my number's decimal part seems to be 1, I've got an unespected result

Steps to Reproduce:
1. in A1 =(RANDBETWEEN(1;9)*10+1)/10
2. in B1 =INT((A1-INT(A1))*60)


Actual Results:
the result in B1 should be 6, but in some cases is 5
Type F9 to change the values.

Expected Results:
always 6


Reproducible: Sometimes


User Profile Reset: No



Additional Info:
With other decimal numbers than 1, there's no problem
Comment 1 Mike Kaganski 2021-03-17 12:36:42 UTC
FAQ: https://wiki.documentfoundation.org/Faq/Calc/Accuracy

0.1 is not representable in binary. If binary representation a number 'x.1' happens to be slightly greater than x.1 (something like x.1000000000000012412), then you will have 6; if it happens to be slightly smaller (like x.0999999999999998712), you get 5.
Comment 2 Sebastien COGEZ 2021-03-17 14:24:36 UTC
Ok, got it
Comment 3 Mike Kaganski 2022-12-28 11:24:13 UTC

*** This bug has been marked as a duplicate of bug 63242 ***