Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there an easier way to do this?
Message
From
27/11/2006 09:00:00
 
 
To
26/11/2006 15:46:06
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01172477
Message ID:
01172638
Views:
20
Thank you Professor Nedeljkovich.

>>I have two four place decimal numbers (eg .0123 and .4321) I need to combine them into a unique decimal value for processing. As they are map coordinates, they cannot just be added together because sum of .0123 + .4321 is the same as .4321 + .0123. I'm thinking I could multiply each times 10,000 to remove the decmals. Then convert them to a string value, and using the 'additive' operator, butt them together so that they look like this 01234321 when stored in a table. For processing I would need to convert the number to an eight place decimal value using val() and dividing the result by 100000000. After processing, the resulting decimal output would be coverted to eight places if neccesary and split into two four place value and converted to a four place decimal value and then to two four place integers to be used as a map coordinates.
>>
>>Is there a better way to code this or am I on the right track?
>
>If the value doesn't need to be a number, you can store
>
>transform(x, "@0")+transform(y, "@0")
>
>or, shorter
>
>substr(transform(x*1000, "@0"),3)+substr(transform(y*1000, "@0"),3)
>
>Which will give you both numbers as hex representation (8 bytes each, i.e. a 16 char string).
>
>now if you are sure that your numbers will always be in the range between 0.0000 and 1.0000, you can just keep that as an integer:
>
>nResult=x*10000+y*10000*0x10000
>
>This would give you an integer, where the upper two bytes hold y, and the lower two hold x (multiplied by 10000). To get your numbers back, you can
>
>x=bitand(nResult, 0xffff)/10000
>y=bitrshift(nResult, 16)/10000
I ain't skeert of nuttin eh?
Yikes! What was that?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform