Group Abstract Group Abstract

Message Boards Message Boards

0
|
7K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Why a function returns two different values in a Notebook and in a Package?

Posted 10 years ago
POSTED BY: Pietro Fezzardi
3 Replies

Looks like a possible problem with Get that is also coming from ToExpression

InputForm@ToExpression["Hold[\[LeftCeiling]Log[2,1+Abs[scale[x]-1]]\[RightCeiling]+1]"]

(* InputForm=Hold[Ceiling[Log[2, 1 + Abs[scale[x] - 1]]]*(Plus[1])] *)
Posted 10 years ago

Thanks, I will look in to it and see what happens with your suggestions. But given that the code is the same in the Notebook and the Package, I still don't understand, why are the results different?

POSTED BY: Pietro Fezzardi

1024 result from the package code comes from BitShiftLeft[2, 9]

1552 result from the Front End implementation comes from BitShiftLeft[3, 9] + 16

The difference in the BitShiftLeft first argument 2 vs 3: 2 + 2^(ne[x] - 1) - 1

Private ne in 2^(ne[4] - 1) - 1 is returning 1

The Package is interpreting [LeftCeiling] stuff [RightCeiling] + 1 into

Times[Ceiling[Log[2, Plus[1, Abs[Plus[scale[x], -1]]]]], Plus[1]]

I would go ahead and replace that line with

Ceiling[Log[2, 1 + Abs[scale[x] - 1]]] + 1

Then it will work for you.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard