Mr. Cohen, who seems more comfortable on the fringes, and sniffs at M.F.A. programs — “A degree in servitude,” he called them in a 2010 interview — doesn’t seem at first like the best-equipped person to bridge the divide between literature and technology. He writes his first drafts in longhand on legal pads. His book collection, which spills from shelves into neatly organized stacks on the floor, includes books in German and Hebrew, languages he reads fluently and has translated. The first sentence of “Book of Numbers,” takes aim at tech adopters, using a crude expletive to tell those who are reading the book on a screen not to bother. “I’ll only talk if I’m gripped with both hands,” the narrator continues.

Image Mr. Cohen imagined a world with extensive surveillance years ago. Credit... Danny Ghitis for The New York Times

Mr. Cohen tried to tackle the unwieldy subject from the inside. He read more than 180 books, including wonky treatises about surveillance and cyber security, books about the history and architecture of the Internet, and memoirs and biographies of technological innovators like Bill Gates, Steve Jobs, Alan Turing and Konrad Zuse, a German computer pioneer (a portrait of Mr. Zuse glares down from the wall above Mr. Cohen’s desk). He visited the National Security Agency’s museum of cryptology. He studied technology patents on Google patent search.

He also learned to write computer code, reading books on Python programming and taking online classes. “I was interested in the connections between these algorithms and language,” he said.

Early on, he had turned to his friend Ben Wizner, a lawyer at the American Civil Liberties Union, for feedback. They shared books about surveillance and privacy, and had intense, alcohol-fueled debates. Mr. Wizner, who ended up representing Mr. Snowden, said the depiction of the “surveillance economy” in “Book of Numbers” was alarmingly accurate, and added that he hoped the book would drive a more robust discussion about Internet-enabled surveillance.

“There’s a frustration on the law and advocacy side about how abstract some of these issues can seem to the public,” Mr. Wizner said. “For some people, the novelist’s eye can show the power and the danger of these systems in ways that we can’t.”

Mr. Cohen grew up in a book-filled house in Atlantic City, N.J., and studied composition at the Manhattan School of Music. When he was 20, he moved to Berlin, with money from a music composition prize. “I was broke, just about as broke as I am now,” he said. “I went with this romantic idea that I would just write and live on $300 a month.” To scrape by, he worked as the Central European correspondent for The Forward, and ghostwrote two memoirs by Holocaust survivors.

He published his first short story collection, “The Quorum,” in 2005, and was paid “$50 and beer.” He made incrementally more, in the three- and four-figure range, on his next few books. For his 2010 novel “Witz,” a dark satire about the last Jew on earth that was turned down by at least eight major publishers, he says he received a small advance of around $1,200 from Dalkey Archive Press.