El miércoles, 10 de agosto de 2016, 18:20:11 (UTC-4), digxx escribió:
>
> As far as I understand Julia adjusts the bitsize of an integer when I use 
> BigInt.
> For example n=big(10)^10000 is as many bits as needed.
> Now 2*n is still an integer though dividing makes a bigfloat out of it. 
> How big is the bigfloat? does it "resolve" up to the last integer? Does it 
> increase with size like bigint would?
>

When you create a BigFloat, it has the current default precision. You can 
ask Julia this kind of thing directly:

julia> a = big(10)^10000;

julia> a / 3
3.333333333333333333333333333333333333333333333333333333333333333333333333333363e+9999

julia> precision(ans)
256

julia> set_bigfloat_precision(1000)
1000

julia> a / 3
3.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333332e+9999

julia> precision(ans)
1000

(That was Julia 0.4. In Julia 0.5, use setprecision instead of 
set_bigfloat_precision.)

Please read the manual:

http://docs.julialang.org/en/release-0.4/manual/integers-and-floating-point-numbers/#arbitrary-precision-arithmetic




 

> for example (n/2)^10 is still legid up to the last digit (neglecting the 
> fact that these would be zero in this case anyway)
> When dividing n by an integer and the result is an an integer, how would I 
> achieve this?
> Is there already a simple way?
> For example I could represent n in some basis b and look where the right 
> most digit is zero and then bitshift, but the bitshift I found in the 
> manual mainly << >> .>> etc.. do not work or I'm too stupid
> how am I supposed to use these?
> 3 << ?
>

Reply via email to