Skip to main content
deleted 244 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
NaN=Indeterminate;

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,
        False
    ],
    If[x===\[Infinity]\[Or]x===If[x===∞∨x===-\[Infinity]\[Or]x===NaN∞∨x===NaN,
        True,
        False
    ]
]

bar[x_/;floatQ[x]\[And]x;floatQ[x]∧x!=\[Infinity]\[And]x==∞∧x=!=NaN]:=If[x==0,
    0,
    \[LeftFloor]Log[2⌊Log[2,Abs[x]]\[RightFloor]Abs[x]]⌋
]

foo[x_/;floatQ[x]\[And]x;floatQ[x]∧x!=\[Infinity]\[And]x==∞∧x=!=NaN]:=If[x==0\[Or]bar[x]==1=If[x==0∨bar[x]==1,
    1,
    \[LeftCeiling]Log[2⌈Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+11]]⌉+1
]
BeginPackage["minimal`"]

bar::usage = "bar[float_number]"
foo::usage = "foo[float_number]"

Begin["`Private`"]

NaN=Indeterminate;

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,
        False
    ],
    If[x===\[Infinity]\[Or]x===If[x===∞∨x===-\[Infinity]\[Or]x===NaN∞∨x===NaN,
        True,
        False
    ]
]

bar[x_/;floatQ[x]\[And]x;floatQ[x]∧x!=\[Infinity]\[And]x==∞∧x=!=NaN]:=If[x==0,
    0,
    \[LeftFloor]Log[2⌊Log[2,Abs[x]]\[RightFloor]Abs[x]]⌋
]

foo[x_/;floatQ[x]\[And]x;floatQ[x]∧x!=\[Infinity]\[And]x==∞∧x=!=NaN]:=If[x==0\[Or]bar[x]==1=If[x==0∨bar[x]==1,
    1,
    \[LeftCeiling]Log[2⌈Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+11]]⌉+1
]

End[]

EndPackage[]
NaN=Indeterminate;

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,
        False
    ],
    If[x===\[Infinity]\[Or]x===-\[Infinity]\[Or]x===NaN,
        True,
        False
    ]
]

bar[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0,
    0,
    \[LeftFloor]Log[2,Abs[x]]\[RightFloor]
]

foo[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0\[Or]bar[x]==1,
    1,
    \[LeftCeiling]Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+1
]
BeginPackage["minimal`"]

bar::usage = "bar[float_number]"
foo::usage = "foo[float_number]"

Begin["`Private`"]

NaN=Indeterminate;

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,
        False
    ],
    If[x===\[Infinity]\[Or]x===-\[Infinity]\[Or]x===NaN,
        True,
        False
    ]
]

bar[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0,
    0,
    \[LeftFloor]Log[2,Abs[x]]\[RightFloor]
]

foo[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0\[Or]bar[x]==1,
    1,
    \[LeftCeiling]Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+1
]

End[]

EndPackage[]
NaN=Indeterminate;

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,
        False
    ],
    If[x===∞∨x===-∞∨x===NaN,
        True,
        False
    ]
]

bar[x_/;floatQ[x]∧x!=∞∧x=!=NaN]:=If[x==0,
    0,
    ⌊Log[2,Abs[x]]⌋
]

foo[x_/;floatQ[x]∧x!=∞∧x=!=NaN]:=If[x==0∨bar[x]==1,
    1,
    ⌈Log[2,1+Abs[bar[x]-1]]⌉+1
]
BeginPackage["minimal`"]

bar::usage = "bar[float_number]"
foo::usage = "foo[float_number]"

Begin["`Private`"]

NaN=Indeterminate;

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,
        False
    ],
    If[x===∞∨x===-∞∨x===NaN,
        True,
        False
    ]
]

bar[x_/;floatQ[x]∧x!=∞∧x=!=NaN]:=If[x==0,
    0,
    ⌊Log[2,Abs[x]]⌋
]

foo[x_/;floatQ[x]∧x!=∞∧x=!=NaN]:=If[x==0∨bar[x]==1,
    1,
    ⌈Log[2,1+Abs[bar[x]-1]]⌉+1
]

End[]

EndPackage[]
edited tags
Link
ilian
  • 25.5k
  • 4
  • 117
  • 187
added 344 characters in body
Source Link
fez
  • 103
  • 6
NaN=Indeterminate; 

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,False]
        False
    ],
    If[x===\[Infinity]\[Or]x===-\[Infinity]\[Or]x===NaN,
        True,False]]
        False
    ]
]

bar[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0,
    0,
    \[LeftFloor]Log[2,Abs[x]]\[RightFloor]]Abs[x]]\[RightFloor]
]

foo[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0\[Or]bar[x]==1,
    1,
    \[LeftCeiling]Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+1]1]]\[RightCeiling]+1
]
BeginPackage["minimal`"]

bar::usage = "bar[float_number]"
foo::usage = "foo[float_number]"

Begin["`Private`"]

NaN=Indeterminate; 

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,False]
        False
    ],
    If[x===\[Infinity]\[Or]x===-\[Infinity]\[Or]x===NaN,
        True,False]]
        False
    ]
]

bar[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0,
    0,
    \[LeftFloor]Log[2,Abs[x]]\[RightFloor]]Abs[x]]\[RightFloor]
]

foo[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0\[Or]bar[x]==1,
    1,
    \[LeftCeiling]Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+1]1]]\[RightCeiling]+1
]

End[]

EndPackage[]
NaN=Indeterminate;
floatQ[x_]:=If[NumericQ[x],If[Head[x]=!=Complex,True,False],If[x===\[Infinity]\[Or]x===-\[Infinity]\[Or]x===NaN,True,False]]
bar[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0,0,\[LeftFloor]Log[2,Abs[x]]\[RightFloor]]
foo[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0\[Or]bar[x]==1,1,\[LeftCeiling]Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+1]
BeginPackage["minimal`"]

bar::usage = "bar[float_number]"
foo::usage = "foo[float_number]"

Begin["`Private`"]

NaN=Indeterminate;
floatQ[x_]:=If[NumericQ[x],If[Head[x]=!=Complex,True,False],If[x===\[Infinity]\[Or]x===-\[Infinity]\[Or]x===NaN,True,False]]
bar[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0,0,\[LeftFloor]Log[2,Abs[x]]\[RightFloor]]
foo[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0\[Or]bar[x]==1,1,\[LeftCeiling]Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+1]

End[]

EndPackage[]
NaN=Indeterminate; 

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,
        False
    ],
    If[x===\[Infinity]\[Or]x===-\[Infinity]\[Or]x===NaN,
        True,
        False
    ]
]

bar[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0,
    0,
    \[LeftFloor]Log[2,Abs[x]]\[RightFloor]
]

foo[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0\[Or]bar[x]==1,
    1,
    \[LeftCeiling]Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+1
]
BeginPackage["minimal`"]

bar::usage = "bar[float_number]"
foo::usage = "foo[float_number]"

Begin["`Private`"]

NaN=Indeterminate; 

floatQ[x_]:=If[NumericQ[x],
    If[Head[x]=!=Complex,
        True,
        False
    ],
    If[x===\[Infinity]\[Or]x===-\[Infinity]\[Or]x===NaN,
        True,
        False
    ]
]

bar[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0,
    0,
    \[LeftFloor]Log[2,Abs[x]]\[RightFloor]
]

foo[x_/;floatQ[x]\[And]x!=\[Infinity]\[And]x=!=NaN]:=If[x==0\[Or]bar[x]==1,
    1,
    \[LeftCeiling]Log[2,1+Abs[bar[x]-1]]\[RightCeiling]+1
]

End[]

EndPackage[]
deleted 7204 characters in body
Source Link
fez
  • 103
  • 6
Loading
Source Link
fez
  • 103
  • 6
Loading