Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toExternalString for nonreal RR objects #3631

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions M2/Macaulay2/d/gmp1.d
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,10 @@ tostringRRipointer = tostringRRi;


export toExternalString(x:RR):string := (
if isinf(x) then return if x < 0 then "-infinity" else "infinity";
if isnan(x) then return if sign(x) then "-NotANumber" else "NotANumber";
ng := sign(x);
ngstr := if ng then "-" else "";
if isinf(x) then return ngstr + "infinity_" + tostring(precision(x));
if isnan(x) then return ngstr + "NotANumber_" + tostring(precision(x));
if ng then x = -x;
ex := long(0);
s := getstr(ex, base, 0, x);
Expand All @@ -184,7 +185,7 @@ export toExternalString(x:RR):string := (
);
newlen := max(1,length(s) - nt);
concatenate(array(string)(
if ng then "-" else "",
ngstr,
".",
substr(s,0,newlen),
"p",
Expand Down
1 change: 1 addition & 0 deletions M2/Macaulay2/m2/exports.m2
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export {
"NewOfFromMethod",
"NewOfMethod",
"NoPrint",
"NotANumber",
"Nothing",
"Number",
"NumberedVerticalList",
Expand Down
5 changes: 3 additions & 2 deletions M2/Macaulay2/m2/max.m2
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ toExternalString InfiniteNumber := x -> getAttribute(x,PrintNames)

IndeterminateNumber = new Type of Number
IndeterminateNumber.synonym = "indeterminate number"
indeterminate = new IndeterminateNumber from {}
indeterminate = new IndeterminateNumber from {"indeterminate"}
NotANumber = new IndeterminateNumber from {"NotANumber"}
setAttribute(indeterminate,ReverseDictionary,symbol indeterminate)
toString IndeterminateNumber :=
net IndeterminateNumber :=
toExternalString IndeterminateNumber := x -> "indeterminate"
toExternalString IndeterminateNumber := first
texMath IndeterminateNumber := x -> texMath toString x
numeric(ZZ, IndeterminateNumber) := (prec, x) -> (
numeric(prec, 0) * numeric(prec, infinity))
Expand Down
2 changes: 2 additions & 0 deletions M2/Macaulay2/m2/reals.m2
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ infty := prec -> 1/toRR(prec,0)
numeric InfiniteNumber := infinity -> infinity#0 * infty defaultPrecision
numeric(ZZ, InfiniteNumber) := (prec,infinity) -> infinity#0 * infty prec

Number_ZZ := (x, p) -> numeric(p, x)

ZZ _ RealField :=
QQ _ RealField :=
RR _ RealField := (x,R) -> toRR(R.precision,x)
Expand Down
Loading