Bug 145617 - Documentation for CINT%: inappropriate, incomplete and misleading
Summary: Documentation for CINT%: inappropriate, incomplete and misleading
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.3.0 target:7.4.0 target:7.3....
Keywords:
Depends on:
Blocks: HelpGaps-NewFeatures
  Show dependency treegraph
 
Reported: 2021-11-10 16:53 UTC by Christopher Yeleighton
Modified: 2021-12-03 18:29 UTC (History)
4 users (show)

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 Christopher Yeleighton 2021-11-10 16:53:17 UTC
Description:
The documentation for the function CINT% is inappropriate, incomplete and misleading.


Steps to Reproduce:
1. Examine the documentation for CInt Function.


Actual Results:
CInt Function
Converts any string or numeric expression to an integer.

Syntax:
CInt (Expression)
Return value:
Integer

Parameters:
Expression: Any numeric expression that you want to convert. If the Expression exceeds the value range between -32768 and 32767, LibreOfficeDev Basic reports an overflow error. To convert a string expression, the number must be entered as normal text ("123.5") using the default number format of your operating system.

This function always rounds the fractional part of a number to the nearest integer.

Error codes:
5 Invalid procedure call

Example:
Sub ExampleCountryConvert
    MsgBox CDbl(1234.5678)
    MsgBox CInt(1234.5678)
    MsgBox CLng(1234.5678)
End Sub

Expected Results:
CInt Function
Converts any string or numeric expression to an integer.

Syntax:
CInt (Expression)
Return value:
Integer

Parameters:
Expression: Any numeric or string expression that you want to convert.

If the Expression is a number that exceeds the value range between -32768 and 32767, LibreOfficeDev Basic reports an overflow error.

A string parameter will be interpreted in a locale-specific way as specified in the operating system settings for floating-point number format.  Initial blanks will be skipped and all trailing characters beginning with a non-digit will be ignored.  Initial signs are allowed but any space following them will cause the string to be converted to 0.

If the trimmed string begins with a base indicator &O or &H, the string will interpreted in the corresponding base using an universal integer format.  Trailing letters that do not represent digits in the corresponding base (including ALL letters in base 8) immediately following the number will cause the function to unconditionally return 0.

This function always rounds the fractional part of a number, if applicable, to the nearest integer.

Error codes:
5 Invalid procedure call

Example:
Sub ExampleCountryConvert
IF CINT% (" 1A ") <> 1 THEN STOP
IF CINT% ("+ 1") <> 0 THEN STOP
IF CINT% (" 1,235E2") <> 124 THEN STOP
IF CINT% (" 1235E-1") <> 124 THEN STOP
IF CINT% (" +&O10:A ") <> &O10 THEN STOP
IF CINT% (" -&H10 ") <> -&H10 THEN STOP
IF CINT% (" &O10A ") <> 0 THEN STOP
IF CINT% (" -&H0A:X ") <> -&HA THEN STOP
End Sub


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
<URL: https://help.libreoffice.org/7.3/en-US/text/sbasic/shared/03100500.html >
Comment 1 Xisco Faulí 2021-11-23 10:11:04 UTC
Hi Mike,
Any opinion on this ?
Comment 2 Mike Kaganski 2021-11-23 10:25:52 UTC
I would like our documentation to be as complete and correct as possible. However, this proposal is unclear and partially incorrect to me.

1. It shows the existing text and proposed text verbatim, requiring me to inspect it carefully to find the difference (it would be nice if it just skipped unchanged parts, and suggested "change this: BLAH - to this: BLEH").
2. It tells about operating system settings (and the older version did, too), which is wrong. What matters is LibreOffice configured locale settings, which *may* be (and by default is) defaulting to OS locale (but e.g. not to OS-configured custom separators - we have a issue for that).

The proposal goes into details about as subtle matter as space between sign and following number, which I have never met in any reasonable programming language documentation (it's OK to mention trimming leading space).

When mentioning hex/octal notation, we need to refer to an article about literals (do we have it yet?).

Anyway, I fail where current help is "inappropriate" or "misleading". I would appreciate if users used appropriate wording trying to *not* demean the effort that others put into writing something that would simply not exist otherwise. Improving existing text is always easier than creating something new.
Comment 3 Mike Kaganski 2021-11-23 14:20:17 UTC
https://gerrit.libreoffice.org/c/help/+/125708 (it does not cover possible clarification of examples - I do not intend to improve that part, whoever wants to do it please assign the task to yourself and add the missing bits).
Comment 4 Xisco Faulí 2021-11-23 14:30:16 UTC
Hi Mike,
thanks for looking into it
Comment 5 Christopher Yeleighton 2021-11-23 20:47:16 UTC
(In reply to Mike Kaganski from comment #3)
> https://gerrit.libreoffice.org/c/help/+/125708 

trinning?
Comment 6 Christopher Yeleighton 2021-11-23 20:48:44 UTC
claculating?
Comment 7 Mike Kaganski 2021-11-23 20:51:57 UTC
(In reply to Christopher Yeleighton from comment #5, comment #6)

Thanks - fixed.
Comment 8 Christopher Yeleighton 2021-11-23 21:15:35 UTC
(In reply to Mike Kaganski from comment #2)

> Anyway, I fail where current help is "inappropriate" or "misleading". I
> would appreciate if users used appropriate wording trying to *not* demean
> the effort that others put into writing something that would simply not
> exist otherwise. Improving existing text is always easier than creating
> something new.

No, you succeeded in removing the offending parts just right, thank you very much.  Also, I did not comment on anybody’s effort.
Comment 9 Commit Notification 2021-11-24 09:28:01 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/89f81cf2f81e2594a68956755114c733aeb041c5

tdf#145617: Mention an alternative exponent notation
Comment 10 Commit Notification 2021-12-01 22:26:36 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/b127658216cdbac1becdba794ea97f8f8b219e15

tdf#145617 break dense paragraph in bullets for CInt
Comment 11 Commit Notification 2021-12-03 18:29:46 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/help/commit/18df2a92e4a63ca68e8479051d58d678daf70917

tdf#145617 break dense paragraph in bullets for CInt