|
Hi guys,
How do I change a double value from negative to positive. i.e. -3.14 to 3.14
Please help
sasa
|
|
|
|
|
|
double negativeDouble = 0 - positiveDouble;
|
|
|
|
|
Just for the sake of completeness...
double positiveValue = (double)Math.Abs( negativeValue );
|
|
|
|
|
Use the negation operator (-):
double x = -3.14;<br />
x = -x;
---
b { font-weight: normal; }
|
|
|
|
|
Thank you guys, I went ahead using ftemp=0-ftemp;
Appreciate the response
sasa
|
|
|
|
|
Actually, that should be:
ftemp = 0.0 - ftemp;
The value 0 is an integer value. You should use a double value to make sure that your value doesn't get converted to an integer before the calculation.
The zero value is superflous, though:
ftemp = -ftemp;
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: The value 0 is an integer value. You should use a double value to make sure that your value doesn't get converted to an integer before the calculation.
Just to be pedantic, the integer value (0) would be widened to a double value (0.0), not the other way around.
|
|
|
|
|
|
You've got to be kidding me!! I find it interesting to see the miriad of solutions people come up with for such a simple problem. But DAMN, the performance and memory implications of this one, in a high-use situation, are just sickening!! Good job!!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: But DAMN, the performance and memory implications of this one, in a high-use situation, are just sickening!
yep. Apparently there are people with so little knowledge of math, they didn't realize a simple -1 multiplication would swap the sign.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I weep for the software of tomorrow!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: I weep for the software of tomorrow!
I weep for the software of today (aka VS2005)
|
|
|
|
|
Yeah, I'm feeling that pain too! I'm dying to get my hands on the SP, but causiously. It seems every other SP that comes out breaks more than it fixes...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Judah Himango wrote: yep. Apparently there are people with so little knowledge of math, they didn't realize a simple -1 multiplication would swap the sign.
Or so little knowledge of the language that they don't realize that there is a negation operator that is specially made for just changing the sign of a number.
---
b { font-weight: normal; }
|
|
|
|
|
Judah Himango wrote: Convert it to a string, remove the first character, then parse the value from the string.
That's no moon, it's a space station. - Obi-wan Kenobi
|
|
|
|
|
i try to make program for (sheduler student table ) in univercity
student can have lecture any time from 8 am to 2 pm in all days acept sunday ...
|8-9|9-10|10-11|11-12|12-1|1-2|
----+------------------------------
mon | | | | | | |
----+------------------------------
tue | | | | | | |
----+------------------------------
wed | | | | | | |
----+------------------------------
thu | | | | | | |
----+------------------------------
fri | | | | | | |
----+------------------------------
my qastions
1- how can make this table in WinApp form
2- how can make drag and drop to Cell in ( Mon 11-12) to ( thu 10-11)
just the how make drag and drop
Palestine
|
|
|
|
|
|
I think in the States students are used to seeing
M T W R F S
8-9
9-10
10-11
11-12
...
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Hi!
I have a problem, if i have a treeview which is filled with allot of TreeNodes and for some reason i need to restart the treeview, can i restart it to the same visible mode that it was before, i mean if i opened node one and its chield and its chield, and now i restart it, i mean create it again can i visibly show the same childs as it was before the restart, this is of corse when the treeview does not change.
Thanks
|
|
|
|
|
You can, but there's no magic way to do this. When you clsoe the TreeView, record the node hierarchy and each node's expanded state. When you want to restore your nodes, you'll have to do this manually based on the information you previously recorded.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
|
Hi.
I want to catch the audio from modem when somebody calls my computer by phone.
i.e that must convert the analog sound that arrives to modem, to digital in the form that I can get it.
Now I can establish a call via modem commands.
I prefer that do this in managed code in c#
-- modified at 11:31 Tuesday 15th August, 2006
Best wishes
|
|
|
|
|
i use list view that have control in this page
http://www.codeproject.com/cs/miscctrl/ListViewEmbeddedControls.asp
* if i have database with 3 recode ex:
------
field 1
------
5
7
8
-----
i want to add 3 row in the listView with first colum must be button(ClickMe)
the problem new
-----------------
1 - how i make my app when i click in the fisrt (ClickMe) button -> open new Form with 5 as parameter - > new Form(5);
and second button new Form(7);
Palestine
|
|
|
|
|
First, you need to get the data out of your database. To do that, use ADO.NET. If you have an ADO.NET-specific question, ask in the ADO.NET forum[^].
Once you've got your data out of the database, you can provide a constructor that takes an integer for each form you want to pass:
class MyForm : Form
{
public MyForm(int integer)
{
...
}
}
You can then construct it like
MyForm form = new MyForm(5);
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|