|
As the others mentioned it doesn't create data.
Just for kicks take a look at exactly what it is doing.
Let's use 0.1 as our test number.
(Hex in raw byte order)
0.1 float is 0x3dcccccd
0.1 double is 0x3fb999999999999a
What happens when you cast from a float to a double:
0x3dcccccd -> 0x3fb99999a0000000 - contrast with ...
0x3fb999999999999a - most accurate representation
As you can see it does zero out the unknown part.
The ieee float format uses a 24 bit mantissa (3 bytes).
The ieee double format uses a 11-bit exponent, plus 1 bit sign (1.5 bytes before start of mantissa).
So if we look at the double the mantissa and sign are in 0x3fb leaving 99999a (3 bytes) for the mantissa, which match the 3 bytes of mantissa in the float (cccccd) - i.e. same precission.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I want my CEdit box only receive the number 0-9. And if other keys were pushed down, it will not be displayed in the CEdit box.
What can I do?
I looked up in the MSDN, But I didn't find any method.
|
|
|
|
|
set the property of your editbox
Number - True
|
|
|
|
|
|
Hi all
How do we delete say some 50bytes from the begning of the file, and move the remaining contents to the begning
of the file.
my file size is very large so i don't want to use the memcpy or memmove functions to achieve this.
i want to know is ther any function in c/c++/vc++(MFC CFile)
that can help solve this problem
thanks and regards
pradish
|
|
|
|
|
No, I don't believe so. I think you need to read and rewrite the files. I'd be inclined to read a bit at a time and copy to a new file then delete/rename. rather than have it all in memory at once.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I agree with Christian .. best you could do is memory map the file and read it and write it to another file starting from a x byte offset into the file (where x can be your 50) etc .. you can optimise the read/write buffers etc although windows should do a good job for you, especially if you memory map it ..
'G'
|
|
|
|
|
They're both right (accept Christian ment bytes not bits).
Here's a couple of old fashion ways (still apply):
// Slow
1) Read byte 50+i. // where i starts at 0.
2) Copy byte 50+i to byte i.
3) Repeat 1 and 2, util you reach the end of the file.
4) Set file size to the original size - 50.
// Faster
1) Open a temporary file.
2) Copy all the bytes, starting at byte 50, from original file to the temporary file.
3) Delete the original file.
4) Rename the temporary file to the origninal files name.
// THIS FITS BETTER (given enough memory)
1) Read the entire (original) file into memory.
2) Copy the data back to the file starting with byte 50.
(no memcpy or memmove required).
3) Set file size to the original size - 50.
Use your imagination, there are other ways. Even if there was a function call to do this for you, it would still do it the same way.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Below is apart of my program:
else
{
SktAddr.sin_family=AF_INET;
SktAddr.sin_port=htons(ReadPortNo("[TCP.FLDATA.SRV.COMMUNICATION]"));
SktAddr.sin_addr.s_addr=htonl(INADDR_ANY)
But it have the error below:
error C2227: left of '.sin_family' must point to class/struct/union
error C2227: left of '.sin_port' must point to class/struct/union
error C2227: left of '.sin_addr' must point to class/struct/union
error C2227: left of '.s_addr' must point to class/struct/union
Can teach me how to solve these problem.....
|
|
|
|
|
1983ttj wrote:
SktAddr.sin_family=AF_INET;
Is SktAddr a class, or an instance of a class ? If it's a class, make an instance, and if it's an instance, include the header to tell this code what it means.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
how to know that SktAddr is a class? how to make an instance?
|
|
|
|
|
1983ttj wrote:
how to know that SktAddr is a class?
Well, if it's not an instance, it's a class.
A class definition looks like this
class MyClass
{
/....
An instance looks like this
MyClass myClass;
The capitalisation is not important, except in that the language is case sensitive. That is, an instance can start with a capital, and a class with lowercase.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a dialog and only got one start button. I do some program about ListenThread and got around 4 errors. All of the errors is about undefined identifier.I don't know how and where to declare it. In the Dlg.h file?
Below is apart of my code:
UINT ListenThread(LPVOID lParam)
{
char szMessage[300];
wsprintf(szMessage, "(ListenThread) - Starting TCP/IP Initialisations.");
//WriteSysLog(szMessage);
ServerSkt = socket ( AF_INET, SOCK_STREAM, 0 );
return 0;
}
I have header files as shown below:
Resource.h
StdAfx.h
TCPTest.h
TCPTeseDlg.h
and the errors are below
error C2065: 'ServerSkt' : undeclared identifier
error C2065: 'socket' : undeclared identifier
error C2065: 'AF_INET' : undeclared identifier
error C2065: 'SOCK_STREAM' : undeclared identifier
Error executing cl.exe.
where should I declare ?
-- modified at 0:09 Wednesday 31st August, 2005
|
|
|
|
|
What is SktAddr ? Is it a class ? Is it an instance of a class ? Is it something you copied out of a book and you have no idea what it is ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I was given a source code from my supervisor and the source code have around three thousand of line. He want me to break some of the source code into a simple program. So I designed a dialog with a start button and try some part of the source code that my supervisor gave me. And I actually not good in programming so the program got alot of error that I don't know how to solve it.
|
|
|
|
|
That just doesn't work. A large program is littered with dependancies. Your supervisor needs a smack in the head.
1983ttj wrote:
And I actually not good in programming so the program got alot of error that I don't know how to solve it.
I can't believe how many people who are 'not good at programming' are being paid to do it, and left to sink or swim by their supervisors. Buy a book and learn in your own time, then find a better job. Or, just find another job. Seriously. I can't give more specific advice based on what you posted, except to say that you're lost at sea. Ask specific questions, and I'll be glad to help you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
-- modified at 4:47 Wednesday 31st August, 2005u create the the application usingDialog based using AppWizard then chooose Windows Socket option it will automatically add #include afxsock.h .u can check it in stdafx.h
|
|
|
|
|
u create the the Dialog based application using AppWizard then chooose Windows Socket option it will automatically add #include <afxsock.h>.u can check it in stdafx.h
|
|
|
|
|
1983ttj wrote:
error C2227: left of '.sin_family' must point to class/struct/union
Do u forget to include afxsock.h/winsock2.h header file in your project....+ also link your project with ws2_32.lib to save project from linker error too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
We know that you can add a new tab view when you want to add a new source file in visual.net
I also want to do like that.
Could you give me some free example.
Thanks a lot! I do hope you could give me a hand
|
|
|
|
|
The tab control is a basic control, available to any MFC app.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for you reply,but I mean that I want a tabbed view not tab control
And i want a example programme because i am a green hand
Jack
|
|
|
|
|
Searching[^] this very site gave me a number of hits.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello again guys.
Ok, here's my project situation.
My project launch an application that shows an html page contain japanese letters/characters from the created file. Before the html page launch, there's a hidden process that the html page to be launch is created. I successfully did this process except when the application launch, the html displays unformatted character encoding. I check the html file that has been created and open it in an editor, I see no problem with the html file. In html file, the character set is "euc-jp". But I wonder why, when the application launch, html page displays different from it should be. I wonder if there's any character encoding rule in writing into a file. I only used the fopen and fwrite function for writing html code in a file.
I would like to ask if someone knows about character set encoding in writing to a file. Any help is much appreciated.
Thanks a lot guys out there.
With great power comes a great responsibility.
|
|
|
|