|
No, because you that only works if you were to include the number you were taking away from in the calculation. Between -1 and 1 (for instance), there are only 2 numbers - suppose you start from -1, then you add 1 to get 0 and add 1 again to get 1. You don't take the initial -1 into account. Now don't confuse the OP - he's already stated his maths isn't that good.
|
|
|
|
|
Okey. Let's say we got some values like this:
int min = -10;
int max = 20;
int result = 0;
int step = 0;
result = min + max;
step = result / 100;
midRange = result / 2;
result = 10;
step = 5;
midRange 2.5;
The problem is that from -10 to 20, there is 30 steps, right?
*This math should I have learned in my first school year -_- lol.
|
|
|
|
|
Yes, there are 30 steps. The mistake you are making here is that you have step as an integer - which would come out as 0 here. Try changing it to a double or float and see what value you get then.
|
|
|
|
|
Oh, thats rigth, I cahnged it to double, and was then able to get a a precise value.
I think I get it from now on. thanx for all the help I got from all!
|
|
|
|
|
|
In line 6 you comment "// Getting the difference...", but the equation on the same line is adding. To get a difference, you have to subtract:
result = max - min;
Let's use values in this equation:
result = 20 -(-10);
result = 20 + 10;
result = 30;
Ciao,
luker
modified 8-Nov-12 9:41am.
|
|
|
|
|
You are proberly right about that, but if we need to get the how many steps there is form -10 to 10, then we have to plus? 
|
|
|
|
|
<quote>we have to plus?
Actually we have to subtract: Steps = Max - Min
In case Min is less than zero, this evolves in a doulbe-minus if we write the actual numbers down. But you don't have to worry about that if you leave the computation to a machine. Just tell it to "Max - Min" and it will take care of the sign on its own.
Question was for the step count. Number of possible positions is (stepCount + 1).
+---+---+---+---+---+---+---+
-3 -2 -1 0 1 2 3 4
stepCount = 4 - (-3) = 7
positionCount = stepCount + 1 = 8
Ciao,
luker
|
|
|
|
|
Would not be like range from -1000 to 1000?
With step of 1? That would be 2001 values not 100? Am i missing something?
No more Mister Nice Guy... >: |
|
|
|
|
|
Here's a little trick for you - open up Calc.exe and type in 10000-20000. See what answer you get.
|
|
|
|
|
Equal -10000.
what is you point? I'm not getting it?
|
|
|
|
|
My point is that his calculation is wrong. Ignore it - between 10000 and -10000, there are only 20000 integers, not 20001.
|
|
|
|
|
I am not confusing anyone. It depends (forgive me if I am not using proper terminology) of range. Is this closed? Opened? From both or from one side? For example range <-1,1> have 3 integers. Range <-1,1) have 2 ints. (-1,1> have 2 too. But (1,1) have only 0. Your substraction is range (-10000,-10000>. For me in this case you should either take closed from or opened from both range. But question is not clear about that som I can be wrong.
No more Mister Nice Guy... >: |
|
|
|
|
|
There are some different solutions and you have to decide.
There are 20001 values (in complete range) or having 20000 values (in reduced range -9999 to 10000)
In first case there should be 101 tags (-10000, -9800, ..., -200, 0, +200, ..., +9800, +10000) (same interval, 200)
In second case you could use 100 tags (-9999 to -9800, -9799 to -9600, ..., -199 to 0, 1 to 200, ... 9801 to 10000) (same blocksize, 200).
Otherwise the tags wouldn't have same size and same interval.
------------------------------
Author of Primary ROleplaying SysTem
How do I take my coffee? Black as midnight on a moonless night.
War doesn't determine who's right. War determines who's left.
|
|
|
|
|
Hi, Im using Oracle database and I cant find the solution for SELECT,UPDATE,DELETE,INSERT query to access the ORACLE tables using VARIABLE in C# . .
Im using this Code and it dosnt work? what should I need to do? I think there is something wrong in (cmd.Parameters.Add) when I do assign VARIABLES.
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO OUT_TEXT_NORM (KEY,LANG_ID,TEXT, PRIO) VALUES (:key,:lang_id,:text,:prio)";
cmd.Parameters.Add(":key", OracleDbType.Varchar2, 60).Value = key;
cmd.Parameters.Add(":lang_id", OracleDbType.Int32).Value = lang_id;
cmd.Parameters.Add(":text", OracleDbType.Varchar2, 4000).Value = text;
cmd.Parameters.Add(":prio", OracleDbType.Int32).Value = prio;
cmd.ExecuteNonQuery();
|
|
|
|
|
Are you getting an error of some type?
Can you explain what does not work.
|
|
|
|
|
It say's Invalid command for CMD
|
|
|
|
|
Try renaming the text-column; it's probably a reserved word.
|
|
|
|
|
Is there any other way in assinging variables?
|
|
|
|
|
Nope.
Still, I don't think the code is faulty; it's more likely to be the Sql command. A column named "TEXT" might be confusing to the parser.
|
|
|
|
|
Today the ports were getting confused and Win'7 was lying to me again.
I first removed the device (Control panel ---> Devices and Printers ---> removed the external device which was connected by BlueTooth.)
I then went to device manager, and deleted all the ports that I knew were bogus.
I then went back to Devices and Printers
I added the known device.
Windows reported that COM20 was back on the list.
There were a total of 4 Com Ports
COM1
COM2
COM18
COM20
Within a few minutes, I watched, king of the clueless, as Windows started adding more Com ports, specifically,
COM25
COM28
COM29
COM30
Following this, Win'7 begins lying to me again, telling me that I have two COM20 ports.
This was exactly and precisely the same problem I had which kept me chasing clouds for 10 days, and I do not want to repeat the previous behavior.
There are a total of 4 USB devices connected to this machine
One USB Hub with three devices attached
-- A debugging device for the embedded system
-- An external hard drive
-- The bluetooth device
There is one other USB cable connected to thin air
What on earth is going on ?
Why is Win'7 reporting two COM20 ports ?
I welcome and thank anyone who can provide any answer behind all this.
|
|
|
|
|
You need to ask this in the hardware forum. This has nothing at all to do with C#.
|
|
|
|
|
Sorry, NewBee NoClue, Mods ? Can you move this ?
Can I ?
|
|
|
|
|
I must be slipping. This used to work...
The XML file:
<?xml version="1.0" encoding="utf-8"?>
<Properties>
<PropertyEditor>
<Property ViewName = "Characteristics" PropertyName = "ValueLand" DisplayName = "Land Value" DataType = "numeric"/>
<Property ViewName = "Characteristics" PropertyName = "ValueStructure" DisplayName = "Structure Value" DataType = "numeric"/>
<Property ViewName = "Characteristics" PropertyName = "ValuePersonal" DisplayName = "Personal Value" DataType = "numeric"/>
</PropertyEditor>
</Properties>
and the code to read it
private void GetPropertyData()
{
propertyDatas = new List<PropertyData>();
string path = Path.GetDirectoryName(Application.ExecutablePath) + @"\EditorProperties.xml";
XmlTextReader reader = new XmlTextReader(path);
XmlDocument doc = new XmlDocument();
XmlNode node = doc.ReadNode(reader);
foreach (XmlNode childNode in node.ChildNodes)
{
foreach (XmlAttribute att in childNode.Attributes)
{
PropertyData propertyData = new PropertyData
{
ViewName = att.Attributes["Characteristics"].Value,
PropertyName = att.Attributes["PropertyName"].Value,
DisplayName = att.Attributes["DisplayName"].Value,
DataType = att.Attributes["numeric"].Value
};
propertyDatas.Add(propertyData);
}
}
}
Now, for some reason, it reads the 'XML' line, then the code skips out on the first foreach.
What's wrong here?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: What's wrong here?
I cannot say whether or not this used to work; but when debugging, it tries to iterate the children of the first element. The first element being the <xml> tag, and it has no children.
XmlTextReader reader = new XmlTextReader(path);
XmlDocument doc = new XmlDocument();
reader.MoveToContent();
XmlNode node = doc.ReadNode(reader);
http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.movetocontent.aspx[^]
|
|
|
|