Skip to main content
bebarth
Community Expert
Community Expert
November 30, 2023
Question

Math.acosh() Javascript Method with Acrobat doesn't work (???)

  • November 30, 2023
  • 2 replies
  • 1102 views

Hi,

Unless I'm mistaken, I just realized that the Math.acosh() Javascript method doesn't work with Acrobat. So I recreated it with a function:

function acosh(x) {
  return Math.log(x+Math.sqrt(Math.pow(x,2)-1));
}

Has anyone heard of this and know why? Are there other Math methods that don't work?

Thanks

@+

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
November 30, 2023

This is a verision thing. Acrobat does not incorporate the latest version of core JavaScript. So there are a number of JS features that do not work. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
bebarth
Community Expert
bebarthCommunity ExpertAuthor
Community Expert
November 30, 2023

Apparently all hyperbolic functions don't work!
If you're interested, here are the associated functions:

 

 

//********
// cosh **
//********
function cosh(x) {
	return (Math.exp(x)+Math.exp(-x))/2;
};

//*********
// acosh **
//*********
function acosh(x) {
	return Math.log(x+Math.sqrt(Math.pow(x,2)-1));
}

//********
// sinh **
//********
function sinh(x) {
	return (Math.exp(x)-Math.exp(-x))/2;
};

//*********
// asinh **
//*********
function asinh(x) {
	if (x===-Infinity) return x;
	else return Math.log(x+Math.sqrt(Math.pow(x,2)+1));
}

//********
// tanh **
//********
function tanh(x) {
	var a=Math.exp(+x);
	var b=Math.exp(-x);
	return a==Infinity?1:b==Infinity?-1:(a-b)/(a+b);
};

//*********
// atanh **
//*********
function atanh(x) {
	return Math.log((1+x)/(1-x))/2;
};

 

 

@+

Nesa Nurani
Community Expert
Community Expert
November 30, 2023

Math.trunc() doesn't work.

bebarth
Community Expert
bebarthCommunity ExpertAuthor
Community Expert
December 1, 2023

Hi,

Instead of, you can use this function:

function trunc(x) {
	return Number(x.toString().substr(0,x.toString().indexOf(".")));
};

@+