Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BINTOC function doesn't sort numeric data correctly
Message
From
04/12/2001 16:39:54
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00589393
Message ID:
00589524
Views:
31
This message has been marked as the solution to the initial question of the thread.
>>>Hi everybody,
>>>
>>>In the compound index I use BINTOC function to convert everything to string. So my index expression will look like:
>>>ccode+town+street+bintoc(stNum)+StNumExt... where stNum is Numeric 4. However, we found, that it sorts things incorrectly, e.g. 109 appears before 84. So, does it mean, what this function could not be used or I have some sort of data corruption...?
>>>
>>>Thanks in advance.
>>
>>Are you sure ? If your stNums <= 0x7FFFFFFF then it'd sort right.
>>Cetin
>
>What is 0x7FFFFFFF in decimal? My manager showed me, that 109 was sorted prior to 89. I haven't examined it closely, but it seems, like they were sorted incorrectly. So, does it mean, what BINTOC() doesn't work correctly with numbers or I need to investigate this problem for the particular file?

Did you ever try ? 0x7FFFFFFF perhaps?

>
>Here is an index expression: UPPER(STR(galleysort,3)+registry+city+STR(recgrp,1)+street+BINTOC(stnum,2)+stnumext+unit) I see by my own, what 109 preceeds 89.

Because BINTOC() creates a binary string, BINTOC(109,2) > BINTOC(89,2). You get errors with # > 65535, < 0, containing fractions, etc. BINTOC(x,4) handles # > 2,000,000,000. All it does is it adds 0x80000000 to the number before converting it to a big-endian string representation of a 32 bit ULONG
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform