• Welcome to Valhalla Legends Archive.
 

Math

Started by Adron, December 15, 2005, 01:23 PM

Previous topic - Next topic

Adron

Calculate 8000 * 0.3 - 8000 * 3 / 10

Comments?

Explicit

I'm awake in the infinite cold.

[13:41:45]<@Fapiko> Why is TehUser asking for wang pictures?
[13:42:03]<@TehUser> I wasn't asking for wang pictures, I was looking at them.
[13:47:40]<@TehUser> Mine's fairly short.

Adron

Quote from: Explicit[nK] on December 15, 2005, 02:11 PM
0?

What version of VB did you use to come to that conclusion? If you did not, consider why this was posted to the VB forum... ;)

Warrior

Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

QwertyMonster

I got 0 too (I used Visual basic 6).

Explicit

Quote from: Adron on December 15, 2005, 02:45 PM
Quote from: Explicit[nK] on December 15, 2005, 02:11 PM
0?

What version of VB did you use to come to that conclusion? If you did not, consider why this was posted to the VB forum... ;)

Pffffft, who needs VB when you have your fingers?  I counted out to 8000, and chopped off a finger to attain the three-tenths fraction, then smashed my hands together and found nothing was left. :)
I'm awake in the infinite cold.

[13:41:45]<@Fapiko> Why is TehUser asking for wang pictures?
[13:42:03]<@TehUser> I wasn't asking for wang pictures, I was looking at them.
[13:47:40]<@TehUser> Mine's fairly short.

Adron

Hmm, weird. I did that in VB6, and did not get 0. Just typed it in the debug window,


?8000 * 0.3 - 8000 * 3 / 10

Ringo

#7
I got -8.88178419700125E-14
[Edit]: and -1500 in a string

MyndFyre

Quote from: Adron on December 15, 2005, 04:09 PM
Hmm, weird. I did that in VB6, and did not get 0. Just typed it in the debug window,


?8000 * 0.3 - 8000 * 3 / 10


Perhaps the debug window doesn't follow order of operations?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Hdx

Wow another reason ive droped VB.
But one question. WTF!?!?!
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Adron

Quote from: MyndFyre on December 15, 2005, 04:46 PM
Perhaps the debug window doesn't follow order of operations?

Well, it originally came from a larger program. So it's not just the debug window.

l)ragon

Quote from: Adron on December 15, 2005, 01:23 PM
Calculate 8000 * 0.3 - 8000 * 3 / 10

Comments?
'VB6
Private Sub Form_Load()
Dim a As Double
Dim b As Double
Dim x As Double
Dim y As Double
    a = 8000 * 0.3     '2400
    b = 8000 * 3 / 10  '2400
    x = a - b
    y = 8000 * 0.3 - 8000 * 3 / 10
Debug.Print x 'Real answer
'= 0
Debug.Print y 'Real Problem
'= -8.88178419700125E-14
End Sub

Is this problem only with subtraction? (Addition works fine.)

I guess the solution to this is to create your own calculation processor.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

Ringo

Currency can do it all in one:
Const Zero As Currency = 8000 * 0.3 - 8000 * 3 / 10

Adron

Quote from: Ringo on December 15, 2005, 11:10 PM
Currency can do it all in one:
Const Zero As Currency = 8000 * 0.3 - 8000 * 3 / 10

Currency can't handle the size of the answer so it rounds to zero. I'll give you another test for that though:

Const Answer As Currency = Fix(8000 * 0.3)

Ringo

hmm, what about CDec(CDbl(8000 * 0.3) - CDbl(8000 * 3 / 10))?