Click here to Skip to main content
16,004,587 members
Home / Discussions / Algorithms
   

Algorithms

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder28-Jul-09 2:32
cofounderChris Maunder28-Jul-09 2:32 
PinnedHow to get an answer to your question PinPopular
Chris Maunder16-Mar-09 10:13
cofounderChris Maunder16-Mar-09 10:13 
QuestionJust a simple question about rounding negative numbers, I hope. Pin
Jeremy Falcon1-Sep-24 15:38
professionalJeremy Falcon1-Sep-24 15:38 
I think I know the answer to this, but would love some feedback from math peeps much better than me at this. After some Googling, I still don't know of anything definitive. So....

When it comes to rounding off positive numbers, fortunately everyone is one the same page:
Round Off
7.5 => 8.0
7.4 => 7.0

We get the idea. And when it comes to rounding up, we all know to move away from zero and rounding down we move towards zero. Now, that's all good and well... for positive numbers. But, what about negative numbers?
Round Off
-7.5 => 8.0 or 7.0?
-7.4 => 8.0 or 7.0?

I suppose it depends on the definition of up and down. When less than zero would up be moving towards zero and down be moving away from zero?

If so, then is this correct?
Round Off
-7.5 => 7.0
-7.4 => 8.0

Or am I off my rocker? Laugh | :laugh:

Much appreciated.

Edit: I just found out that the terms "up" and "down" are just colloquialisms and don't have really any bearing on math. So, when negative "up" would be down and down would be "up". So, something like this would be true...

-1.4 rounds to -1
-1.5 rounds to -2

Anywho, if anyone can confirm I'm not off my rocker with this, would totally appreciate it.

Jeremy Falcon

AnswerRe: Just a simple question about rounding negative numbers, I hope. Pin
Mircea Neacsu1-Sep-24 17:02
Mircea Neacsu1-Sep-24 17:02 
GeneralRe: Just a simple question about rounding negative numbers, I hope. Pin
Jeremy Falcon2-Sep-24 3:22
professionalJeremy Falcon2-Sep-24 3:22 
GeneralRe: Just a simple question about rounding negative numbers, I hope. Pin
Mircea Neacsu2-Sep-24 4:10
Mircea Neacsu2-Sep-24 4:10 
GeneralRe: Just a simple question about rounding negative numbers, I hope. Pin
Jeremy Falcon2-Sep-24 4:41
professionalJeremy Falcon2-Sep-24 4:41 
Questionbfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
TalespinTales1-Jan-24 7:18
TalespinTales1-Jan-24 7:18 
AnswerRe: bfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
Dave Kreskowiak1-Jan-24 9:26
mveDave Kreskowiak1-Jan-24 9:26 
GeneralRe: bfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
TalespinTales1-Jan-24 9:31
TalespinTales1-Jan-24 9:31 
GeneralRe: bfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
Dave Kreskowiak1-Jan-24 10:46
mveDave Kreskowiak1-Jan-24 10:46 
GeneralRe: bfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
TalespinTales1-Jan-24 10:54
TalespinTales1-Jan-24 10:54 
GeneralRe: bfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
Dave Kreskowiak1-Jan-24 12:36
mveDave Kreskowiak1-Jan-24 12:36 
AnswerRe: bfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
Gerry Schmitz1-Jan-24 11:04
mveGerry Schmitz1-Jan-24 11:04 
AnswerRe: bfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
jschell2-Jan-24 6:32
jschell2-Jan-24 6:32 
AnswerRe: bfs, dfs, a* & dijkstra algorithms - find the shortest route Pin
Malcolm Arthur McLean 21-Jun-24 4:47
Malcolm Arthur McLean 21-Jun-24 4:47 
Question[SOLVED] Representing Metadata Pin
Richard Andrew x6429-Dec-23 13:52
professionalRichard Andrew x6429-Dec-23 13:52 
AnswerRe: [SOLVED] Representing Metadata Pin
Gerry Schmitz30-Dec-23 6:50
mveGerry Schmitz30-Dec-23 6:50 
GeneralRe: [SOLVED] Representing Metadata Pin
Richard Andrew x6430-Dec-23 12:52
professionalRichard Andrew x6430-Dec-23 12:52 
QuestionLocking pattern to protect a critical List<> with many worker threads Pin
Richard Andrew x6426-Dec-23 8:02
professionalRichard Andrew x6426-Dec-23 8:02 
AnswerRe: Locking pattern to protect a critical List<> with many worker threads Pin
Mircea Neacsu26-Dec-23 8:17
Mircea Neacsu26-Dec-23 8:17 
GeneralRe: Locking pattern to protect a critical List<> with many worker threads Pin
Richard Andrew x6426-Dec-23 8:39
professionalRichard Andrew x6426-Dec-23 8:39 
AnswerRe: Locking pattern to protect a critical List<> with many worker threads Pin
jschell27-Dec-23 5:27
jschell27-Dec-23 5:27 
GeneralRe: Locking pattern to protect a critical List<> with many worker threads Pin
Richard Andrew x6427-Dec-23 5:32
professionalRichard Andrew x6427-Dec-23 5:32 
GeneralRe: Locking pattern to protect a critical List<> with many worker threads Pin
harold aptroot27-Dec-23 8:01
harold aptroot27-Dec-23 8:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.