# Exporting large numbers in WDX format

I have a list of 10 000 3×3 matrices in Mathematica. The entries are rational numbers. I would like to write this to a file so I can load it again in the future. After some fussing with file formats, it looks like the one I'd like to use is "WDX". However, some of my numbers are quite large, and don't seem to want to export. Does anyone know a good way around this issue?

I can reproduce the sort of problem I'm having just by running:

Export[NotebookDirectory[] <> "junk.wdx", {42838805520130}, "WDX"]


which returns

BinaryWrite::nocoerce: 42838805520130 cannot be coerced to the specified format. >>


I've used the "MX" file format, which works well, but I want to be able to import the file on another computer. Other file types don't seem to work so well. (For example, the "Table" format bizarrely introduces extraneous commas.)

-
It looks like exports to WDX only accept 32bit signed integers. This restriction doesn't seem to be documented and is, I'd say, also rather unexpected for a format that is supposed to be able to store any type of Mathematica expressions. –  Sjoerd C. de Vries Jun 10 '13 at 20:16
ExportString[(2^31)^x, "WDX"] works, but ExportString[(2^31)^1, "WDX"] doesn't. It seems that as long as it is part of an expression it's OK, but when it's used as a pure number, or a list of numbers it fails. ExportString[List[2^31], "WDX"] fails, but ExportString[List2[2^31], "WDX"] works. Looks like a bug to me. –  Sjoerd C. de Vries Jun 10 '13 at 20:23
A good alternative should be Save. –  Sjoerd C. de Vries Jun 10 '13 at 20:28
I'd encourage you to report this as a bug. It seems that, after updating Mathematica itself to support 64-bit machine numbers in version 9, WRI has forgotten to do the same for the WDX format. (This problem does not arise in version 8.) –  Oleksandr R. Jun 10 '13 at 21:53
a better alternative than save is something like Export["file.mz", Compress[expression], "String"] –  Szabolcs Jun 11 '13 at 8:33