hello all,
I have a problem, I have a DOUBLE value like that
4065 4000 0000 0000
and I want to convert it to a DWORD like that:
4065 4000
if I do result=(DWORD)M yDouble it end with AA(170)
wich I don't want.
Believe me or not but I spent 4 hours on this,
I cannot shift the bits, the compiler complaint with double,
it say: "bad left operand" "bad right operand" while it work
well with DWORD.
I'm puzzled, any help appreciated (VC++ 5.0)
Dan
Jul 22 '05
12 2323
DanSteph wrote: hello all,
I have a problem, I have a DOUBLE value like that
4065 4000 0000 0000
and I want to convert it to a DWORD like that: 4065 4000
if I do result=(DWORD)M yDouble it end with AA(170) wich I don't want.
Believe me or not but I spent 4 hours on this, I cannot shift the bits, the compiler complaint with double, it say: "bad left operand" "bad right operand" while it work well with DWORD.
Hi, maybe this can help (used union to split 4 bytes into 2x2 bytes:
#include <iostream>
using std::cout;
using std::endl;
union mysplit {
unsigned int d;
unsigned short int i [2];
};
void splitme (unsigned int myint, unsigned short int &low, unsigned
short int &high) {
mysplit temp;
temp.d=myint;
low=temp.i[0];
high=temp.i[1];
}
int main () {
unsigned short int testint1, testint2;
unsigned int testint = 2864434397;
//AA BB CC DD ... BUT COMPILER WARNS (C90 compatible only)
//is just for testing
splitme (testint, testint1, testint2);
cout << testint1 << " ; " << testint2 << endl;
/* testint1: CCDD = 52445,
testint2: AABB = 43707 */
return 0;
}
regards marbac
DanSteph wrote: hello all,
I have a problem, I have a DOUBLE value like that
4065 4000 0000 0000
and I want to convert it to a DWORD like that: 4065 4000
Hi, maybe this can help (used union to split 4 bytes into 2x2 bytes)
But i did it with int and short int:
#include <iostream>
using std::cout;
using std::endl;
union mysplit {
unsigned int d;
unsigned short int i [2];
};
void splitme (unsigned int myint, unsigned short int &low, unsigned
short int &high) {
mysplit temp;
temp.d=myint;
low=temp.i[0];
high=temp.i[1];
}
int main () {
unsigned short int testint1, testint2;
unsigned int testint = 2864434397;
//AA BB CC DD ... BUT COMPILER WARNS (C90 compatible only)
//is just for testing
splitme (testint, testint1, testint2);
cout << testint1 << " ; " << testint2 << endl;
/* testint1: CCDD = 52445,
testint2: AABB = 43707 */
return 0;
}
regards marbac
DanSteph wrote: hello all,
Believe me or not but I spent 4 hours on this, I cannot shift the bits, the compiler complaint with double, it say: "bad left operand" "bad right operand" while it work well with DWORD.
Hi, maybe this can help (used union to split 4 bytes into 2x2 bytes)
But i did it with int and short int.
#include <iostream>
using std::cout;
using std::endl;
union mysplit {
unsigned int d;
unsigned short int i [2];
};
void splitme (unsigned int myint, unsigned short int &low, unsigned
short int &high) {
mysplit temp;
temp.d=myint;
low=temp.i[0];
high=temp.i[1];
}
int main () {
unsigned short int testint1, testint2;
unsigned int testint = 2864434397;
//AA BB CC DD ... BUT COMPILER WARNS (C90 compatible only)
//is just for testing
splitme (testint, testint1, testint2);
cout << testint1 << " ; " << testint2 << endl;
/* testint1: CCDD = 52445,
testint2: AABB = 43707 */
return 0;
}
I hope that i understood you correctly.
double has a sign, "mantisse" and an exponent ... maybe you want to
extract those?
regards marbac? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cindy liu |
last post by:
Hi,
In .Net, how to convert a string to a double?
Thanks in advance!
Cindy
|
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
|
by: Pascal |
last post by:
Why does this not work, and how should i do this convert in stead:
string x = double.MinValue.ToString();
double y = Convert.ToDouble(x);
i get this exception:
An unhandled exception of type 'System.OverflowException' occurred in mscorlib.dll
Additional information: Value was either too large or too small for a Double.
Pascal
|
by: Sam |
last post by:
How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on
following guideline found at Internet?
To convert Julian date to Gregorian date:
double JD = 2299160.5;
double Z = Math.Floor(JD+0.5);
double W = Math.Floor((Z - 1867216.25)/36524.25);
double X = Math.Floor(W/4);
|
by: Daniel Walzenbach |
last post by:
Hi,
I wonder if somebody could explain me the difference between Double.Parse and Convert.ToDouble. If I'm not mistaken they are implemented differently (I though for a moment they might be the same like cint(anInt) and cType(anInt, System.Int32) but I checked with ildasm) - if I didn't made a mistake.
So when to use which syntax? Is there any performance penalty when using the one over the other or does anybody knows any differences?
'...
| |
by: David Scemama |
last post by:
Hi,
I'm writing a program using VB.NET that needs to communicate with a DOS
Pascal program than cannot be modified. The communication channel is through
some file databases, and I have a huge problem writing VB Double values to
the file so as the Pascal program can read them as Pascal Real values.
I've managed to find the algorithm to read the Pascal Real format and
convert it to a VB Double, but I cannot figure out the opposite...
|
by: Eric BOUXIROT |
last post by:
hi,
i must convert all of these eVC++ prototypes to use with VB.NET....
DLLEXPORT long F_BDO_MessageBoxOK(char *IN_title, char *IN_msg );
DLLEXPORT long F_BDO_MessageBoxOUINON(char *IN_title, char *IN_msg );
DLLEXPORT long F_BDO_CalculAXplusB(short int *IN_Tab_entree ,int IN_taille
,
double *OUT_Tab_sortie_freq ,
double *OUT_Tab_sortie, double IN_A,
|
by: PeterK |
last post by:
I am trying to set Public overridable CreditlimitS() as
System.Data.SqlTypes.SqlMoney to Creditlimit as Double
like CreditLimitS=creditlimit
and get this error "Value of type double cannot be converted to
System.Data.SqlTypes.SqlMoney "
How do I get creditlimit into creditlimitS?
There seems to be no conversion function.
TIA
|
by: Edwin Knoppert |
last post by:
In my code i use the text from a textbox and convert it to a double value.
I was using Convert.ToDouble() but i'm used to convert comma to dot.
This way i can assure the text is correct.
However it seems this convert is determined by the local settings and comma
is indeed used as decimal separator.
Is there another way to convert a dotted value to a double variable?
Like 1234.5 and not 1234,5
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |