473,799 Members | 2,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Double Jeopoardy

d1 and d2 are numbers we can store as doubles (8 bytes).

d1 > 0
d2 > 0
d1 < d2

Now s1 and s2 are strings of length 8 bytes. (We can ignore unicode here).

Into s1 and s2 we copy the 8 bytes from d1 and d2 respectively.

Does it follow that s1<s2, (or s1 is ordered before s2) when sorted on a
text or binary compare?

Why?

Why do I ask? Well, if we could prove that this is so (s1<s2 => d1<d2) then
we could order arrays of numbers by using the Wizhook.SortStr ingArray
method.

Why would I want to do that? ... No particular reason ... I have a bunch of
other sorting procedures.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #1
14 2006
WizHook is in A03 so it's safe to use for a while even though it's hidden
and undocumented.

Interesting talk about it here though:
http://www.utteraccess.com/forums/ac...ess561560.html

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
Secure Hosting and Development Solutions for ASP, ASP.NET, SQL Server, and
Access

"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message
news:Xn******** **********@130. 133.1.4...
d1 and d2 are numbers we can store as doubles (8 bytes).

d1 > 0
d2 > 0
d1 < d2

Now s1 and s2 are strings of length 8 bytes. (We can ignore unicode here).

Into s1 and s2 we copy the 8 bytes from d1 and d2 respectively.

Does it follow that s1<s2, (or s1 is ordered before s2) when sorted on a
text or binary compare?

Why?

Why do I ask? Well, if we could prove that this is so (s1<s2 => d1<d2) then we could order arrays of numbers by using the Wizhook.SortStr ingArray
method.

Why would I want to do that? ... No particular reason ... I have a bunch of other sorting procedures.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)

Nov 12 '05 #2
Lyle Fairfield wrote:
d1 and d2 are numbers we can store as doubles (8 bytes).

d1 > 0
d2 > 0
d1 < d2

Now s1 and s2 are strings of length 8 bytes. (We can ignore unicode here).

Into s1 and s2 we copy the 8 bytes from d1 and d2 respectively.

Does it follow that s1<s2, (or s1 is ordered before s2) when sorted on a
text or binary compare?

Why?

Why do I ask? Well, if we could prove that this is so (s1<s2 => d1<d2) then
we could order arrays of numbers by using the Wizhook.SortStr ingArray
method.

Why would I want to do that? ... No particular reason ... I have a bunch of
other sorting procedures.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)


Since they are different storage mediums (ex...how many times do you get the
first 3 bytes of a double?) I would suggest you store them into a string left
padded. Since that method adds overhead, I doubt I'd use it.

We've seen where 1,10,100 come before 2, 20, 200 in a string sort....unless
padded.

Nov 12 '05 #3
Salad <oi*@vinegar.co m> wrote in news:40******** *******@vinegar .com:
Lyle Fairfield wrote:
d1 and d2 are numbers we can store as doubles (8 bytes).

d1 > 0
d2 > 0
d1 < d2

Now s1 and s2 are strings of length 8 bytes. (We can ignore unicode
here).

Into s1 and s2 we copy the 8 bytes from d1 and d2 respectively.

Does it follow that s1<s2, (or s1 is ordered before s2) when sorted on
a text or binary compare?

Why?

Why do I ask? Well, if we could prove that this is so (s1<s2 => d1<d2)
then we could order arrays of numbers by using the
Wizhook.SortStr ingArray method.

Why would I want to do that? ... No particular reason ... I have a
bunch of other sorting procedures.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)


Since they are different storage mediums (ex...how many times do you get
the first 3 bytes of a double?) I would suggest you store them into a
string left padded. Since that method adds overhead, I doubt I'd use
it.

We've seen where 1,10,100 come before 2, 20, 200 in a string
sort....unless padded.


sigh ...

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #4
On Jan 19 2004, 01:58 pm, Lyle Fairfield <Mi************ @Invalid.Com>
wrote in news:Xn******** **********@130. 133.1.4:
Why do I ask? Well, if we could prove that this is so (s1<s2 => d1<d2)
then we could order arrays of numbers by using the
Wizhook.SortStr ingArray method.
This wouldn't be particularly fast, having first allocate strings then sort
them. So I'd stick with those other procedures. Note that this doesn't
answer your original question.
Why would I want to do that? ... No particular reason ... I have a
bunch of other sorting procedures.


--
(remove a 9 to reply by email)
Nov 12 '05 #5
Thoughts only ...

Depends on how you do the copying, Windows systems are little endian so the
bytes are stuffed in from the left hand side, if you just CopyMemory this it
will be the wrong way around.

Doubles are IEEE 8 byte floating numbers so you would also have a problem
with the sign bit.
Terry

"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message
news:Xn******** **********@130. 133.1.4...
d1 and d2 are numbers we can store as doubles (8 bytes).

d1 > 0
d2 > 0
d1 < d2

Now s1 and s2 are strings of length 8 bytes. (We can ignore unicode here).

Into s1 and s2 we copy the 8 bytes from d1 and d2 respectively.

Does it follow that s1<s2, (or s1 is ordered before s2) when sorted on a
text or binary compare?

Why?

Why do I ask? Well, if we could prove that this is so (s1<s2 => d1<d2) then we could order arrays of numbers by using the Wizhook.SortStr ingArray
method.

Why would I want to do that? ... No particular reason ... I have a bunch of other sorting procedures.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)

Nov 12 '05 #6

On Tue, 20 Jan 2004 16:48:09 -0000, "Terry Kreft"
<te*********@mp s.co.uk> wrote in comp.databases. ms-access:
Doubles are IEEE 8 byte floating numbers so you would also have a problem
with the sign bit.


Not really. Lyle made clear he was dealing solely with positive
numbers. The sign bit is zero for positive numbers and 1 for negative
numbers, so its a non-issue for the given problem.

Peter Miller
_______________ _______________ _______________ _______________
PK Solutions -- Data Recovery for Microsoft Access/Jet/SQL
Free quotes, Guaranteed lowest prices and best results
www.pksolutions.com 1.866.FILE.FIX 1.760.476.9051
Nov 12 '05 #7

Lyle,

On 19 Jan 2004 18:58:44 GMT, Lyle Fairfield
<Mi************ @Invalid.Com> wrote in comp.databases. ms-access:
d1 and d2 are numbers we can store as doubles (8 bytes).

d1 > 0
d2 > 0
d1 < d2

Now s1 and s2 are strings of length 8 bytes. (We can ignore unicode here).

Into s1 and s2 we copy the 8 bytes from d1 and d2 respectively.

Does it follow that s1<s2, (or s1 is ordered before s2) when sorted on a
text or binary compare?

Why?


Who cares why!

Knowledge for knowledge's sake, right? Isn't that good enough a
reason?

As long as you make sure you get the byte order correct, you can do as
you suggest and compare double values as strings. But since, in
vb/vba, you can't simply cast one value as another as you could in c,
c++, pascal etc, how are you doing the psudeo-casting? If you're,
say, reading in the values from a file, its trivial (just read an
eight byte string at the i/o point where the double is stored) but if
you're working solely in memory (ie you have a double variable, and
you store it in a string) then the manner used is, of course,
critical. If you can clarify how you're doing the casting, I can give
a clearer answer on whether there'd be any problems.

But two quick points are already clear. (1), a binary comparison is
preferable and (2) working with double values as strings will be
slower than leaving them as doubles.
Peter Miller
_______________ _______________ _______________ _______________
PK Solutions -- Data Recovery for Microsoft Access/Jet/SQL
Free quotes, Guaranteed lowest prices and best results
www.pksolutions.com 1.866.FILE.FIX 1.760.476.9051
Nov 12 '05 #8
Peter Miller <pm*****@pksolu tions.com> wrote in
news:gq******** *************** *********@4ax.c om:
As long as you make sure you get the byte order correct, you can do as
you suggest and compare double values as strings. But since, in
vb/vba, you can't simply cast one value as another as you could in c,
c++, pascal etc, how are you doing the psudeo-casting?


API CopyMemory

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #9
On 21 Jan 2004 03:36:31 GMT, Lyle Fairfield
<Mi************ @Invalid.Com> wrote:

That seems risky, because of the byte layout, which is not as innocent
people (not sure that includes you :-)) might expect.
As a test, use the longint &HAABBCCDD&, CopyMemory it, and observe
you're not getting the characters for &HAA, &HBB etc in that order.

-Tom.

Peter Miller <pm*****@pksolu tions.com> wrote in
news:gq******* *************** **********@4ax. com:
As long as you make sure you get the byte order correct, you can do as
you suggest and compare double values as strings. But since, in
vb/vba, you can't simply cast one value as another as you could in c,
c++, pascal etc, how are you doing the psudeo-casting?


API CopyMemory


Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
9895
by: Sydex | last post by:
When I compile code I get error C2664: 'Integration::qgaus' : cannot convert parameter 1 from 'double (double)' to 'double (__cdecl *)(double)' in this part : double Integration::quad2d(double (*func)(double,double)) { nfunc = func ; return qgaus(f1,x1,x2);//error there
20
17842
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; std::vector<double>::size_type size = src.size(); dest.reserve(size); for (std::vector<int>::size_type i = 0;
31
6652
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one variable becomes 364 and the other one becomes 365. Does anyone have any insight to what the problem is? Thanks in advance. Bjørn
10
8662
by: Robert Palma | last post by:
I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx; Declaring func. int process( double *input ) Calling func. as one of the following:
10
18775
by: Bryan Parkoff | last post by:
The guideline says to use %f in printf() function using the keyword float and double. For example float a = 1.2345; double b = 5.166666667; printf("%.2f\n %f\n", a, b);
3
2886
by: BlueTrin | last post by:
I am using a DLL written in C, it uses some pointers on functions, I have defined a wrapper around it in C# which uses some delegates: #region Delegates and Marshalling to call solvopt public delegate double funCallback(double x); public delegate double funcCallback(double x); public delegate void gradCallback(double x, double v); public delegate void gradcCallback(double x, double v);
67
9932
by: lcw1964 | last post by:
This may be in the category of bush-league rudimentary, but I am quite perplexed on this and diligent Googling has not provided me with a clear straight answer--perhaps I don't know how to ask the quesion. I have begun to familiarize myself here with the gcc compiler in a win32 environment, in the form of MinGW using both Dev C++ and MSYS as interfaces. I have recompiled some old math code that uses long double types throughout and...
1
8229
by: JWest46088 | last post by:
I keep getting these error messages: area(double,double) in Rectangle cannot be applied to () return "Area: " + Rectangle.area() + "\tCircumference: " + Rectangle.perimeter(); ^ perimeter(double,double) in Rectangle cannot be applied to () return "Area: " + Rectangle.area() + "\tCircumference: " + Rectangle.perimeter(); ^ setSides(double,double) in Rectangle cannot be applied to (double)...
2
5808
by: Genro | last post by:
#include<stdio.h> #include<TX/graphics.h> #include<time.h> // I need help! struct Krug{ double _x; double _y; double _skox; double _skoy; double _granx1;
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.