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


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

Re: Executing function on Mathematica 8

From Alexei Boulbitch <Alexei.Boulbitch@iee.lu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Executing function on Mathematica 8
Date 2012-02-01 08:47 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jgau7h$eop$1@smc.vnet.net> (permalink)

Show all headers | View raw


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>


Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web