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, 15:42, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
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
So i got to use:
float FRound(double f, BYTE b)
{
char sz[20];
char szFmt[5] = { '%','.','0'+b,' f', 0 };
sprintf(sz, szFmt, f);
return atof(sz);
}
and put :
long nbNiveau = FRound ((y1-y2)/y3+1,0);
On 14 fév, 15:43, Rolf Magnus <ramag...@t-online.dewrote:
Well, that's not the case. In C++, when converting a floating point value
into an integer, the fractional part is always truncated.
now i know it, but what i found strange is that, if i put the same
instruction in watch window(debug), i get the result that i need. (yhi-
ylo)/stepy+1 became 161, in watch window and nbNiveau = 160
Simply_Red wrote:
On 14 fév, 15:42, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
>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
So i got to use:
float FRound(double f, BYTE b)
{
char sz[20];
char szFmt[5] = { '%','.','0'+b,' f', 0 };
sprintf(sz, szFmt, f);
return atof(sz);
}
and put :
long nbNiveau = FRound ((y1-y2)/y3+1,0);
Ugh!... Please don't do that. For any 'f' greater than 1e10
it will overrun the buffer ('sz'), which is how security holes
get created/exploited.
What is your goal here? Is (y1-y2) very close to N * y3 or is
it arbitrary? If it's close, you can always try
long nbNiveau = (y1-y2)/y3 + 1; // your formula
if ((nbNiveau - 1) * y3 < (y1-y2)) // verify!
++nbNiveau; // bump it up!
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:43, Rolf Magnus <ramag...@t-online.dewrote:
>Well, that's not the case. In C++, when converting a floating point value into an integer, the fractional part is always truncated.
now i know it, but what i found strange is that, if i put the same
instruction in watch window(debug), i get the result that i need.
(yhi- ylo)/stepy+1 became 161, in watch window and nbNiveau = 160
Apparently your "watch window" rounds it before outputting. Try
printf("%f", (yhi-ylo)/stepy+1)
and you're likely to see 161 as well. Conversion to text rounds
the value (and lies to you).
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:
i know this, but my pb is that i need
It's best to post in straight English with strange abreviations like
"pb". I assume you mean "problem", but that's not a standard
abreviation in English, except as the chemical name of lead.
Brian
Default User wrote:
Simply_Red wrote:
>i know this, but my pb is that i need
It's best to post in straight English with strange abreviations like
"pb". I assume you mean "problem", but that's not a standard
abreviation in English, except as the chemical name of lead.
V.E.R.A. offes "Pipeline Burst".
Rolf Magnus wrote:
Default User wrote:
Simply_Red wrote:
i know this, but my pb is that i need
It's best to post in straight English with strange abreviations like
"pb". I assume you mean "problem", but that's not a standard
abreviation in English, except as the chemical name of lead.
V.E.R.A. offes "Pipeline Burst".
And we all know how painful that can be.
Brian
On 14 fév, 16:09, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
Ugh!... Please don't do that. For any 'f' greater than 1e10
it will overrun the buffer ('sz'), which is how security holes
get created/exploited.
I don't understand what is le10???
>
What is your goal here? Is (y1-y2) very close to N * y3 or is
it arbitrary? If it's close, you can always try
long nbNiveau = (y1-y2)/y3 + 1; // your formula
if ((nbNiveau - 1) * y3 < (y1-y2)) // verify!
++nbNiveau; // bump it up!
Y1,Y2 and Y3 aren't arbitrary and i know that (y1-y2)/y3 = N
(integer).
and if i use:
long LRound(double f)
{
char sz[20];
char szFmt[5] = { '%','.','0','f' , 0 };
sprintf(sz, szFmt, f);
return atol(sz);
}
On 14 fév, 17:13, "Default User" <defaultuse...@ yahoo.comwrote:
Simply_Red wrote:
i know this, but my pb is that i need
It's best to post in straight English with strange abreviations like
"pb". I assume you mean "problem", but that's not a standard
abreviation in English, except as the chemical name of lead.
Brian
Sorry, this abreviation is used in french.
Simply_Red wrote:
On 14 fév, 17:13, "Default User" <defaultuse...@ yahoo.comwrote:
>Simply_Red wrote:
>>i know this, but my pb is that i need
It's best to post in straight English with strange abreviations like "pb". I assume you mean "problem", but that's not a standard abreviation in English, except as the chemical name of lead.
Brian
Sorry, this abreviation is used in french.
Good to know. c.l.c++ is an English-speaking newsgroup, though. 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: 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: 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: 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...
|
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: 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.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |