0
$\begingroup$

if $x=1.0e38=1.0 * 10^{38}$ and $y=3.0$
i want to find $ (x-x)+y $ and $(x+y)-x$
i think the value of (x-x)+y will be just substract $x-x=0 + y=3.0 = 3.0$
but how can i perfom addition of different base? $(x+y)-x$
i think the idea is addition $(x+y)$ then substract $-x$ using floating point, i tried to convert $y=3.0$ to binary such as $1.1 * 2^1$
but how about $10^{38}$ to binary ?

$\endgroup$
  • $\begingroup$ What happens when you subtract a small number from a very big number? Would precision matter? $\endgroup$ – gnasher729 Jul 31 at 12:21
  • $\begingroup$ @gnasher729 can you explain more? My question is how can i add x+y in different base? $\endgroup$ – devss Jul 31 at 12:23
  • $\begingroup$ Do you think you have enough precision in floating point so that 10^38 and 10^38 + 3 can be distinguished? $\endgroup$ – gnasher729 Jul 31 at 17:55
  • $\begingroup$ @gnasher729 i think it will produce overflow(?) in IEEE754 we only have 8 bits for eksponent and 23 for mantissa , since it will shift 3 to match 38 eksponent , and the addition it produce $10^{38}$ because overflow(?) $\endgroup$ – devss Jul 31 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.