Jump to content

problem to multiplication complex number

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
aimmh

aimmh

    Newbie

  • Members
  • Pip
  • 1 posts
hi
please any one can help me for this code
when i run thes code
Dim x As Double
Dim y As Double
x = Console.ReadLine()
y = Console.ReadLine()


y = y * x

Console.WriteLine(y)
when I input x and y
big number for example
x= 123123123123
y= 123123123123
the resoult will be 1,51593034475614E+22

and when i has correct the code to
Dim x As Double
Dim y As Double
x = Console.ReadLine()
y = Console.ReadLine()


y = y * x

Console.WriteLine(y.ToString("n10"))


the resault was not correct also it was 15,159,303,447,561,400,000,000.0000000000

but the correct resaulrt is 15159303447561417273129
please can any one help me for this code to be correct ?

#2
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
The sad truth is that vb won't handle more numbers so the result won't be exact. However you could do walkarounds to this problem with special made structures/classes. I haven't tried it myself but it seems that there's a built in structure for this called BigInteger: BigInteger Structure (System.Numerics)