Skip to main content
Tweeted twitter.com/StackCodeGolf/status/1276802468475572227
deleted 54 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq m < 10 \$\$ 1 \leq |m| < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq m' < 16 \$\$ 1 \leq |m'| < 16 \$.

Input / Output

Input a non-zeropositive real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, -53
-1, 0 -> -1, 0
-1.25, -2 -> -3.333333333333, -2

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq m < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq m' < 16 \$.

Input / Output

Input a non-zero real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, -53
-1, 0 -> -1, 0
-1.25, -2 -> -3.333333333333, -2

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq |m| < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq |m'| < 16 \$.

Input / Output

Input a positive real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, -53

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

added 58 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq m < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq m' < 16 \$.

Input / Output

Input a non-zero real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, -53
-1, 0 -> -1, 0
-1.25, -2 -> -3.333333333333, -2

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq m < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq m' < 16 \$.

Input / Output

Input a non-zero real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, -53

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq m < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq m' < 16 \$.

Input / Output

Input a non-zero real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, -53
-1, 0 -> -1, 0
-1.25, -2 -> -3.333333333333, -2

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

Became Hot Network Question
added 1 character in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq m < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq m' < 16 \$.

Input / Output

Input a non-zero real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, -53

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq m < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq m' < 16 \$.

Input / Output

Input a non-zero real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, 53

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below).

Details

In scientific notation, all non-zero numbers are written in the form

$$ m \times 10^n $$

Where \$ n \$ is an integer, and \$ m \$ is a real number, \$ 1 \leq m < 10 \$.

Consider scientific notation in base 16.

$$ m \times 10^n = m' \times 16^{n'} $$

\$ n' \$ is an integer, and \$ m' \$ is a real number where \$ 1 \leq m' < 16 \$.

Input / Output

Input a non-zero real number. You may also choice to input \$m\$, and, \$n\$ separately. For all testcase, -100 < n < 100.

Output the number in hexadecimal scientific notation. Could be a single string or two strings. Number \$m\$, and, \$n\$ should also be formatted as hexadecimal strings.

Output as 1.2E3E4 is not allowed due to ambiguous. (1.2E3×104, or 1.2×103E4) You have to use other notations. For example, 1.2E3E+4, 1.2E3, 4, 1.2E3&4, 1.2e3E4, 1.2E3e4, 1.2E3P4, 1.2E3⏨4, 1.2E3*^4 are all acceptable.

Testcases

m, n -> m', n'
1.6, 1 -> 1, 1
6.25, -2 -> 1, -1
1.0, 1 -> A, 0
7.257672195146994, 93 -> d.eadbeef, 4d
1.234567, 89 -> f.83e0c1c37ba7, 49
1, -99 -> 8.bfbea76c619f, -53

You output may be slightly different from given testcase due to floating point errors. But you should keep at least 4 hex digits precision, and \$1 \leq m' < 16\$.

Rule

This is code golf. Shortest codes in each languages win.

deleted 4 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129
Loading
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129
Loading