Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8269 > unrolled thread

Re: Executing function on Mathematica 8

Started byAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
First post2012-02-01 08:47 +0000
Last post2012-02-01 08:47 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Executing function on Mathematica 8 Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2012-02-01 08:47 +0000

#8269 — Re: Executing function on Mathematica 8

FromAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
Date2012-02-01 08:47 +0000
SubjectRe: Executing function on Mathematica 8
Message-ID<jgau7h$eop$1@smc.vnet.net>
Dear mathematica members,

I am new to mathematica and do not know how to enter the following
function and then call it on mathematica 8:

BinExp[num_,d_] := Module[{n,L},
If[d > $MaxPrecision, $MaxPrecision = d];
n = N[num,d];
L = First[RealDigits[n,2]]
];

Any help is appreciated,

Best Regards,
Fadi Abu-Amara


Hi, Fadi,

I think the problem is that the default value returned by $MaxPrecision is Infinity.  Thus, d is always smaller than $MaxPrecision unless, of course, you have fixed the value of $MaxPrecision somewhere before.  What about the following function:

binExp[num_, d_] := First[RealDigits[N[num, d], 2]];

binExp[3.1415926324, 3]

{1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, \
0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, \
0, 1, 1, 0, 1, 0, 0}

??

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu<mailto:alexei.boulbitch@iee.lu>


[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web