CS代考

using ColorBitstring

Copyright By PowCoder代写 加微信 powcoder

Integers are typically 64-bit

printbits(x)

0000000000000000000000000000000000000000000000000000000101100101

x = Int8(-123)
printbits(x)

Can create numbers from their bits by parsing a string.
We need to first create an unsigned integer to avoid issues with overflow

u = parse(UInt8,”10000101″; base=2) # unsigned 8-bit integer
x = reinterpret(Int8, u)
printbits(x)

x = Int8(127)
y = Int8(1)
printlnbits(x)
printlnbits(y)
printbits(x+y)

x * Int8(3)

Variable bit-length integers (BigInt)

x = big(10)

y = (x^x)^x

OverflowError: exponent 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 is too large and computation will overflow

Stacktrace:
[1] (::Base.GMP.var”#throw1#3″)(y::BigInt)
@ Base.GMP ./gmp.jl:584
[2] bigint_pow(x::BigInt, y::BigInt)
@ Base.GMP ./gmp.jl:599
[3] ^(x::BigInt, y::BigInt)
@ Base.GMP ./gmp.jl:604
[4] top-level scope
@ In[29]:2
@ ./boot.jl:373 [inlined]
[6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com