i'm sorry i posted this in other groupes, and i didn't see it, and as
this group is most actif, i repost it here, and sorry for
mutliposting:
Hi,
i'm using VC6, i have this declaration:
typedef struct tagTLimite {
double Debut;
double Fin;
}Limites;
typedef struct TagElemTab {
double NivY;
bool Existe;
std::vector<Lim itesPtLimites;
}ElemTabCont;
void myfunc( )
{
......
ElemTabCont * ContNonOrd;//contour non ordone
long nbNiveau = (yhi-ylo)/stepY +1 ;
ContNonOrd = new ElemTabCont [nbNiveau];
......
}
i don't know why,nbNiveau is equal to (yhi-ylo)/stepY, it didn't
+1????and even if i put:
ContNonOrd = new ElemTabCont [nbNiveau+1]; the size of ContNonOrd =
nbNiveau????
Feb 14 '07
31 1663
On 14 fév, 14:37, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
Simply_Red wrote:
On 14 fév, 14:29, Rolf Magnus <ramag...@t-online.dewrote:
Simply_Red wrote: On 14 fév, 14:12, "Victor Bazarov" <v.Abaza...@com Acast.netwrote: Simply_Redwro te: i'm sorry i posted this in other groupes, and i didn't see it, and as this group is most actif, i repost it here, and sorry for mutliposting :
>>>Hi, i'm using VC6, i have this declaration:
>>>typedef struct tagTLimite { double Debut; double Fin; }Limites;
>>>typedef struct TagElemTab { double NivY; bool Existe; std::vector<Lim itesPtLimites; }ElemTabCont ;
>>>void myfunc( ) { ..... ElemTabCon t * ContNonOrd;//contour non ordone long nbNiveau = (yhi-ylo)/stepY +1 ;
>>What is the type of 'yhi', 'ylo', 'stepY'? What are their values? What value do you get in 'nbNiveau'? What did you expect
>yhi, ylo, stepY are doubles values: 16, 0, 0.1 respectively I get 160 in nbNiveau, and I need 161.
double isn't precise either. Note that 0.1 in binary is a periodic
number that cannot be represented exactly. So instead of 0.1, you
get the closest representable value. As a result, you might get
something like 160.99999999998 , which gets truncated to 160 when
converted to long.
but if 160.999999998 is truncated to 160, 159.99999998 must be
truncated to 159.....
Yes... And?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
when i just put long nbNiveau = (yhi-ylo)/stepY. i get nbNiveau = 160
not 159
On 14 fév, 14:35, Kai-Uwe Bux <jkherci...@gmx .netwrote:
Simply_Red wrote:
i'm sorry i posted this in other groupes, and i didn't see it, and as
this group is most actif, i repost it here, and sorry for
mutliposting:
Hi,
i'm using VC6, i have this declaration:
typedef struct tagTLimite {
double Debut;
double Fin;
}Limites;
typedef struct TagElemTab {
double NivY;
bool Existe;
std::vector<Lim itesPtLimites;
}ElemTabCont;
void myfunc( )
{
.....
ElemTabCont * ContNonOrd;//contour non ordone
long nbNiveau = (yhi-ylo)/stepY +1 ;
ContNonOrd = new ElemTabCont [nbNiveau];
.....
}
i don't know why,nbNiveau is equal to (yhi-ylo)/stepY, it didn't
+1????and even if i put:
How did you tell? Probably you misinterpret some output that we do not see
because your code snippet is incomplete.
and even if i put: ContNonOrd = new ElemTabCont [nbNiveau+1]; the size of
ContNonOrd = nbNiveau????
Again, how did you tell?
Please post a minimal complete program that shows the problem. With the code
fragments from above, there is no way to tell what the problem is
(especially since we do not even know the types of yhi, yhl, and stepY.
Best
Kai-Uwe Bux
bool __declspec(dlle xport) CALLBACK NewMakeContour( LPSAFEARRAY FAR
*saY, VARIANT FAR *pvArray, double yhi, double ylo,double stepX,double
stepY)
{
SAFEARRAYBOUND sabound[1]; // 1-D array
SAFEARRAY FAR* psa = NULL; // SAFEARRAY structure pointer
HRESULT hr; // Operations result
float HUGEP *vbY; // Tableau Contenant tous les points
long UboundY;
double V;
long ptTabRes,ptTabS ource;
hr = SafeArrayAccess Data(*saY, (void HUGEP**)&vbY);
UboundY = (*saY)->rgsabound[0].cElements;
ElemTabCont * ContNonOrd;//contour non ordone
long nbNiveau = (yhi-ylo)/stepY+1 ;// +1 ; je ne sais pas pourquoi il
ne me fait pas le + 1;
ContNonOrd = new ElemTabCont[nbNiveau];
//ContNonOrd = new ElemTabCont[161];//donc je suis obliger de le
faire ici
V = vbY[1];//le premier pt est un pt du contour
ptTabRes = 0;
ptTabSource = 0;
while (FRound(V,3) <= FRound(yhi,3))
{
FindLevelPt(vbY , ptTabSource,Con tNonOrd,ptTabRe s,V,UboundY,ste pX);
ptTabRes++;
V+=stepY;
}
delete[] ContNonOrd;
hr = SafeArrayUnacce ssData(*saY);
return true
}
void FindLevelPt(flo at* TabSource, long& ptTabSource,Ele mTabCont*
ContNonOrd,long ptTabRes,double V, long UBoundY, float StepX) {
Limites XLimites;
ContNonOrd[ptTabRes].NivY = V;
//si on est au niv superieur a V=>pas de point au niveau V
if (FRound(TabSour ce[ptTabSource+1],3) == FRound(V,3))
{
ContNonOrd[ptTabRes].Existe = true;
bool nivDepasse = false;
bool terminer = false;
while (!nivDepasse && !terminer)
{
XLimites.Debut = TabSource[ptTabSource];
bool trouve = false;//true si on trouve la limite du segment
ptTabSource+=3;//le debut a ete deja trouver
while(!trouve && ptTabSource <= UBoundY-3) //-1 z, -2 y -3 x
{
nivDepasse = (FRound(TabSour ce[ptTabSource+1],3) FRound(V,3));
trouve = (FRound(TabSour ce[ptTabSource]-TabSource[ptTabSource-3],
3)>FRound(StepX ,3)) || nivDepasse ;
ptTabSource+=3;
}
if (trouve) {
XLimites.Fin = TabSource[ptTabSource-6];
ptTabSource-=3;//pour pointer au prochain debut.
ContNonOrd[ptTabRes].PtLimites.push _back(XLimites) ;
}
else {//le dernier pt ou la derniere ligne
terminer = true;
XLimites.Fin = TabSource[ptTabSource-3];
ContNonOrd[ptTabRes].PtLimites.push _back(XLimites) ;
}
}
}
else ContNonOrd[ptTabRes].Existe = false;
}
Simply_Red wrote:
>That last statement is beyond me. What do you mean by "the size of ContNotOrd"? How the hell can you know the size? How can it be different from the size you requested?
i just verify in watch window ContNotOrd[160].
I don't know how you do that, but tell me, if you do
int main() { long nbNiveau = 160; char *ContNotOrd = new char[nbNiveau + 1]; }
and "verify in watch window", do you get 160 or 161 _elements_? Do not tell me the last index (it is less by 1 than the size, right?)
when i give a value to ContNotOrd[161] i have a crash,
That's not surprising. If nbNiveau is 160, then you allocate an array with
161 elements, numbered 0 to 160. So if you try to access the element with
index 161, you are going past the end of your array.
and 160 no.....for my example i check the vector of the 160 elem, when
there is no pb it contain _First = 0 _Last = 0 _End = 0.
when i just put long nbNiveau = (yhi-ylo)/stepY. i get nbNiveau = 160
not 159
i was wrong it's 159...........
and if i use float, is there pbs with the precision???
On 14 fév, 15:25, Rolf Magnus <ramag...@t-online.dewrote:
>
That's not surprising. If nbNiveau is 160, then you allocate an array with
161 elements, numbered 0 to 160. So if you try to access the element with
index 161, you are going past the end of your array.
i know this, but my pb is that i need that nbNiveau = 161, and i get
160, i was sure that when the value is betwwen 160.51 and
160.99999999, in long the compilator will replace it with 160
On 14 fév, 15:33, "Simply_Red " <Simply.Re...@g mail.comwrote:
On 14 fév, 15:25, Rolf Magnus <ramag...@t-online.dewrote:
That's not surprising. If nbNiveau is 160, then you allocate an array with
161 elements, numbered 0 to 160. So if you try to access the element with
index 161, you are going past the end of your array.
i know this, but my pb is that i need that nbNiveau = 161, and i get
160, i was sure that when the value is betwwen 160.51 and
160.99999999, in long the compilator will replace it with 160
i wanted to say: i was sure that when the value is betwwen 160.51 and
160.99999999, in long the compilator will replace it with 161
Simply_Red wrote:
[..]
i wanted to say: i was sure that when the value is betwwen 160.51 and
>160.99999999 , in long the compilator will replace it with 161
What in the world made you so *sure* of that? Just curious...
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Simply_Red wrote:
>when i just put long nbNiveau = (yhi-ylo)/stepY. i get nbNiveau = 160 not 159
i was wrong it's 159...........
and if i use float, is there pbs with the precision???
Of course. Just like if you use 'double', only worse.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Simply_Red wrote:
On 14 fév, 15:33, "Simply_Red " <Simply.Re...@g mail.comwrote:
>On 14 fév, 15:25, Rolf Magnus <ramag...@t-online.dewrote:
That's not surprising. If nbNiveau is 160, then you allocate an array
with 161 elements, numbered 0 to 160. So if you try to access the
element with index 161, you are going past the end of your array.
i know this, but my pb is that i need that nbNiveau = 161, and i get 160, i was sure that when the value is betwwen 160.51 and 160.99999999 , in long the compilator will replace it with 160
i wanted to say: i was sure that when the value is betwwen 160.51 and
>160.99999999 , in long the compilator will replace it with 161
Well, that's not the case. In C++, when converting a floating point value
into an integer, the fractional part is always truncated.
On 14 fév, 15:41, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
Simply_Red wrote:
[..]
i wanted to say: i was sure that when the value is betwwen 160.51 and
160.99999999, in long the compilator will replace it with 161
What in the world made you so *sure* of that? Just curious...
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
in vb it's like that, i know that doesn't meen that C++ must do the
same :-( This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven |
last post by:
Hi all
My problem is a little lengthy. But please help me. In my application,
ADO.NET DataSet object is not getting constructed in the Web Service Web
Method called by the Windows Application passing an ADO.NET DataSet Object
as a parameter to the Web Method in Web Service
Debugging using the Soap Extensions, clearly shows that the Serialized
DataSet is passed to the Web Service, but the Web Service Web Method is not
|
by: John |
last post by:
I am new to c++ programming and i just want to make a program that
takes a users name, then converts it to a hex string, then puts it
together in a fixed order.
An example output would be:
Name: John
Output: 84721305
this is my generation code so far
#include <conio.h>
|
by: expertware |
last post by:
Dear friends,
My name is Pamela, I know little about CSS,
but I would like to ask a question
I have an image on a web page within a css layer:
<DIV ID=MyLayer
STYLE = "position: absolute;top:68px; left:563px;
width:640px;height:480px;">
<IMG src="ReportImageBox_12.54.52.png" width=640 height=480></IMG>
|
by: Mitchell Thomas |
last post by:
I hope someone out there can solve my mysterious problem. I have
tried everything imaginable, even paid $35 to Microsoft to help me,
but they were not able to figure out this problem: Here is the
problem:
I recently created a new database in Access 2002. I took data from an
> access 97 database converted one of the tables to access 2002 and then
> imported it into a new table in access 2002. but for some strange
> reason, every once...
|
by: cpptutor2000 |
last post by:
I am compiling and running the following code snippet on a Linux box -
I am really
puzzled by the answers. Could someone please tell me what might be
wrong?
void test(){
int m = 0;
int n = 0;
int i = 0;
int j = 0;
| |
by: weichaoliu |
last post by:
I know that this problem is concerned to GCC. But I hope somebody here
can tell me some detailed things about why.
The version of g++ I'm using is: g++ (GCC) 3.4.4 (mingw special).
The code is:
// BEGIN
#include<iostream>
int main(void)
{
|
by: Webdiyer |
last post by:
Hi,
We all know that the return value of Math.Log(8,2) is 3,but how about
(int)Math.Log(8,2)? On my machine,the return value of (int)Math.Log(8,2) is
strange enough! it's not 3 but 2 ! I've tested other values such as
(int)Math.Log(16,2),(int)Math.Log(4,2),(int)Math.Log(32,2)...et, they all
return the same value as their counterpart Math.Log() methods,only
(int)Math.Log(8,2) is incorrect,is this a .net bug ? I've also tested...
|
by: John |
last post by:
I can't get my head around this!
I have the following code:
<%
.... Code for connection to the database ...
.... Code for retrieving recordset ...
If Not rs.EOF Then
... Do something...
|
by: Chuck Renner |
last post by:
Please help!
This MIGHT even be a bug in PHP!
I'll provide version numbers and site specific information (browser, OS,
and kernel versions) if others cannot reproduce this problem.
I'm running into some PHP behavior that I do not understand in PHP 5.1.2.
I need to parse the HTML from the following carefully constructed URI:
|
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,...
|
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...
| |
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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?
| | |