|
-
May 26th, 2010, 09:53 AM
#1
Thread Starter
Lively Member
How to round Infinite Number
I am trying to round a number but I keep getting an Infinity number. How do I round this.
4000 / 7135 * 100
Here's the code I've tried.
Code:
Round(readVals(0) / Scaling1 * 100 + ActualValueLow1, 2)
FormatNumber(readVals(0) / Scaling1 * 100 + ActualValueLow1, 2)
Brian Henry
Visual Studio 2001 to 2019
Java/Android
ISaGRAF
-
May 26th, 2010, 10:01 AM
#2
Re: How to round Infinite Number
There's an order of operations involved, and I think it is interfering with your calculations:
I was taught this to help remember the order in which things will take precidence:
Please
Excuse
My
Dear
Aunt
Sally
-meaning-
Parenthesis
Exponential
Multiplication
Division
Addition
Subtraction
So... since there is no parenthesis, the first thing that is done is 7135 * 100 =713500
Then the division
4000 / 713500 = 0.0056061667834618079887876664330764
Then your ActualValueLow will get added.... something tells me that's not what you wanted.
But rather:
((4000 / 7135) * 100) + ActualValueLow
((.5606) * 100) = 56.06
56.06 + ActualValueLow
-tg
-
May 26th, 2010, 10:04 AM
#3
Re: How to round Infinite Number
I was taught BODMAS 
B
Brackets first
O
Orders (ie Powers and Square Roots, etc.)
D
Division (tg: I just noticed you have multiplication first?)
M
Multiplication
A
Addition
S
Subtraction
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 26th, 2010, 10:13 AM
#4
Re: How to round Infinite Number
I don't understand the question?
Dim dd As Double = 4000 / 7135 * 100 '=56.061667834618078
What should dd look like after rounding?
-
May 26th, 2010, 10:14 AM
#5
Re: How to round Infinite Number
Yup... multiplication comes first... it should be BOMDAS... not BODMAS .... think about it, Addition and Multiplication are "the same" ... additive... you do your additives first before you take away (division and subtraction).
-tg
More monkiers:
Mary's Violet Eyes Made John Stay Up Night Proposing....
The planets:
Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto (back in the dark ages when Pluto was still considered a planet). I guess John just stays up nights... no more proposals.
-tg
-
May 26th, 2010, 10:26 AM
#6
Re: How to round Infinite Number
tg, Did you check the link I gave above...
Something from that site which I just saw...
The only strange name is "Orders". "Exponents" is used in Canada, and so you might prefer "BEDMAS". There is also "Indices" so that makes it "BIDMAS". In the US they say "Parenthesis" instead of Brackets, so they say "PEMDAS"
In US ~~> it's Multiplication first
I went further down on that page and realized that both are correct...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 26th, 2010, 11:55 AM
#7
Re: How to round Infinite Number
Multiplication == Division and subtraction == addition. Just with inverted numbers.
a * b = a / (1/b)
a + b = a - (-b)
So it doesn't matter whether you do a * b / c as (a*b)/c or a*(b/c).
-
May 26th, 2010, 12:13 PM
#8
Re: How to round Infinite Number
If that's the case... why do I get a different result?
4000 / 7135 * 100
(4000 / 7135) * 100 = 56.06
4000 / (7135 * 100) = 0.005606
BUT
(4000 * 100) / 7135 = 56.06
Personally, I like to include the parenthesis, that way there is no question as to the order of operations.
-tg
-
May 26th, 2010, 12:21 PM
#9
Re: How to round Infinite Number
Well, writing "a / b * c" is arbitrary. It could mean (a/b)*c or a/(b*c), which indeed is not the same.
As far as I know there is no rule on whether you do division or multiplication first, just don't write a/b*c.
In physics, for example, you often see formulas that read:
F = -G/4 pi r2
This means F = -G / (4 pi r2)
But you also see
E = 1/2 m v2
which means
E = (1/2) * m * v2
The only reason no confusion arises is because these formules are well known. In any other situation, just don't use it, use parenthesis or actual fractions (bit hard in text of course).
-
May 27th, 2010, 01:55 AM
#10
Re: How to round Infinite Number
 Originally Posted by koolsid
tg, Did you check the link I gave above...
Something from that site which I just saw...
In US ~~> it's Multiplication first
I went further down on that page and realized that both are correct...
They should "parentheses" everywhere. "brackets" gets used as an umbrella term and people say "round brackets", "square brackets", "curly brackets" and "angle brackets" like it's primary school when they should say "parentheses" (), "brackets" [], "braces" {} and "chevrons" <>. I think chevrons may have another name too that I can't recall.
-
May 27th, 2010, 02:09 AM
#11
Re: How to round Infinite Number
When you see a * b / c this means ONLY that you have to multiply a by b and then divide the result by c. Without parentheses the order of operations with equal priority goes from left to right (and * and / are of equal priority).
In math formulas like this:

You should evaluate the bottom part first:
Code:
T = m * v^2 / (1 - v^2 / c^2 + Math.Sqrt(1 - v ^2 / c ^2))
Last edited by cicatrix; May 27th, 2010 at 02:14 AM.
-
May 27th, 2010, 03:30 AM
#12
Re: How to round Infinite Number
 Originally Posted by cicatrix
When you see a * b / c this means ONLY that you have to multiply a by b and then divide the result by c.
You can divide b by c and multiply that by a, or divide a by c and multiply that by b. It's all the same thing, so in this case you don't need parentheses.
(a * b) / c is the same as a * (b / c) or even (a / c) * b.
 Originally Posted by cicatrix
Without parentheses the order of operations with equal priority goes from left to right (and * and / are of equal priority).
I don't know of any such rule and in 'my field' (physics) this rule is often not true. For another example, this:
I = P / 4 pi r2
is a well known formula and it is written like that very often, even though it should be written (and calculated) as
I = P / (4 pi r2)
If the rule you mention holds true always then it would have been
I = (P / 4) pi r2
something completely different.
But this notation is not official and is simply wrong because it is ambiguous.
Also, I think exponents are evaluated right-to-left, so that:
2^3^4^5 = 2^(3^(4^5)) = giant overflow (something like (10244)5
and not ((2^3)^4)^5 = 1152921504606846976
-
May 27th, 2010, 03:38 AM
#13
Re: How to round Infinite Number
 Originally Posted by NickThissen
You can divide b by c and multiply that by a, or divide a by c and multiply that by b. It's all the same thing, so in this case you don't need parentheses.
(a * b) / c is the same as a * (b / c) or even (a / c) * b.
Well, maybe my example did not illustrate my point. Here:
a / b * c means you should divide a / b and then multiply the result by c
in this case
(a / b) * c <> a / (b * c)
so, without parentheses the operators are evaluated from left to right.
I don't know of any such rule and in 'my field' (physics) this rule is often not true. For another example, this:
I = P / 4 pi r 2
is a well known formula and it is written like that very often, even though it should be written (and calculated) as
I = P / (4 pi r 2)
I = P / 4 * pi * r2 in terms of math should be evaluated as:
1. a = r ^ 2
2. b = P / 4
2. c = b * pi
3. d = c * a
And any programming language will evaluate it in the precisely that order.
In Physics (see my post above) they use fractions and your example should be written like this:
Code:
P
I = --------------
4 * Pi * r2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|