Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
3

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

Community Expert ,
Nov 30, 2023 Nov 30, 2023

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

@+

TOPICS
JavaScript , PDF
729
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2023 Nov 30, 2023

Math.trunc() doesn't work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2023 Nov 30, 2023
LATEST

Hi,

Instead of, you can use this function:

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

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2023 Nov 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2023 Nov 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;
};

 

 

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines