<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - BASIC: Data Type Characters with literals don't affect resulting value type"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=130476">130476</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>BASIC: Data Type Characters with literals don't affect resulting value type
</td>
</tr>
<tr>
<th>Product</th>
<td>LibreOffice
</td>
</tr>
<tr>
<th>Version</th>
<td>Inherited From OOo
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>UNCONFIRMED
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>BASIC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>libreoffice-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mikekaganski@hotmail.com
</td>
</tr></table>
<p>
<div>
<pre>Consider this code:
<span class="quote">> sub typesnames
> ' Integer % - doesn't work, Long &
> ' This should print Integer Long, but prints Integer Integer
> MsgBox TypeName(&hff) & " " & TypeName(&hff&)
> end sub</span >
As mentioned in comment, is should output "Integer Long", but gives "Integer
Integer" instead. The trailing data type characters # and & at the literals
should explicitly define the type of the literal, instead of using the default
handling depending on the value of the number.
The code works in Excel as expected, taking value type characters into account.
The impact of the problem is that it's impossible to explicitly define the size
of the value, e.g. when using bitwise operations. Consider the following code:
<span class="quote">> Sub ApplyMask
> a = &h0F0F0F0F&
> b = &h0000FF00&
> MsgBox "&h" & Hex(a And b)
> End Sub</span >
The code applies the mask b to number a, and is expected to output "&hF00", but
actually outputs "&hF0F0F00", because b is handled as Integer, which is
negative, which then gets converted into corresponding negative Long when used
in bitwise "And", with all higher bits set, which distorts the mask into
&hFFFFFF00&.
Tested with Version: 6.4.0.3 (x64)
Build ID: b0a288ab3d2d4774cb44b62f04d5d28733ac6df8
CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: GL; VCL: win;
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: CL
and with OpenOffice.org 3.2.0
OOO320m12 (Build:9483)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>