Skip to main content
deleted 4 characters in body
Source Link
andre314
  • 19k
  • 1
  • 37
  • 73

When one transformscopies an output containing machine-precision numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with again all the trailing 0s.

I need to Round the output values so that the input form isstays short (It is not a problem of number formatting/rendering since the numerical values can be changed a little bit in this operation).

Tests already done, without success :

First, a preamble that shows that this is possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

When one transforms an output containing machine-precision numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with all the trailing 0s.

I need to Round the output values so that the input form is short (It is not a problem of number formatting/rendering since the numerical values can be changed in this operation).

Tests already done, without success :

First, a preamble that shows that this is possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

When one copies an output containing machine-precision numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with again all the trailing 0s.

I need to Round the values so that the input form stays short (It is not a problem of number formatting/rendering since the numerical values can be changed a little bit in this operation).

Tests already done, without success :

First, a preamble that shows that this is possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

title changed
Source Link
andre314
  • 19k
  • 1
  • 37
  • 73

How to avoid Copy-paste with annoying trailing 0s during rounding of machine-precision numbers

When one transforms an output containing machine-precision numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with all the trailing 0s.

I need to Round the output values so that the input form is short (It is not a problem of number formatting/rendering since the numerical values can be changed in this operation).

Tests already done, without success :

First, a preamble that shows that this is possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

How to avoid trailing 0s during rounding of machine-precision numbers

When one transforms an output containing machine-precision numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with all the trailing 0s.

I need to Round the output values so that the input form is short (It is not a problem of number formatting/rendering since the numerical values can be changed in this operation).

Tests already done, without success :

First, a preamble that shows that this possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

Copy-paste with annoying trailing 0s

When one transforms an output containing machine-precision numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with all the trailing 0s.

I need to Round the output values so that the input form is short (It is not a problem of number formatting/rendering since the numerical values can be changed in this operation).

Tests already done, without success :

First, a preamble that shows that this is possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

added 2 characters in body; edited title
Source Link
andre314
  • 19k
  • 1
  • 37
  • 73

How to avoid trailing 0s during rounding of machineprecisionmachine-numbersprecision numbers

When one transforms an output containing machineprecisonmachine-numbersprecision numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with all the trailing 0s.

I need to Round the output values so that the input form is short (It is not a problem of number formatting/rendering since the numerical values can be changed in this operation).

Tests already done, without success :

First, a preamble that shows that this possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

How to avoid trailing 0s during rounding of machineprecision-numbers

When one transforms an output containing machineprecison-numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with all the trailing 0s.

I need to Round the output values so that the input form is short (It is not a problem of number formatting/rendering since the numerical values can be changed in this operation).

Tests already done, without success :

First, a preamble that shows that this possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

How to avoid trailing 0s during rounding of machine-precision numbers

When one transforms an output containing machine-precision numbers to a input, many trailing 0s appears.

For example :

Evaluate the following expression :

{{41.`,19.200000000000003`},
 {41.`,39.5`},
 {33.6`,49.300000000000004`},
 {33.2`,59.800000000000004`}, 
 {33.2`,61.800000000000004`}}

{{41., 19.2}, {41., 39.5}, {33.6, 49.3}, {33.2, 59.8}, {33.2, 61.8}}

Then copy-paste this output. The result is a input cell with all the trailing 0s.

I need to Round the output values so that the input form is short (It is not a problem of number formatting/rendering since the numerical values can be changed in this operation).

Tests already done, without success :

First, a preamble that shows that this possible

niceValue=49.3
niceValue //InputForm  

49.3
49.3

Then, a example of a difficult case :

irritatingValue=49.300000000000004`  
irritatingValue //InputForm  

49.3
49.300000000000004

Unsuccessfull attempts :

This seems to work :

Round[irritatingValue,1. 10^-6] //InputForm

49.3

But this does not :

Round[irritatingValue,1. 10^-5] //InputForm    

49.300000000000004

so the "solution" Round[..., 1. 10^-n] is inacceptable. Because the problem is certainly due to the binary representation of numbers that we see ultimately in base 10, I have tried also things like : Round[..., 256 $MachineEpsilon] and Round[..., 2^-10] , without success.

Chop[...] doesn't seem neither to bring a solution.

added 11 characters in body
Source Link
andre314
  • 19k
  • 1
  • 37
  • 73
Loading
added 1 character in body
Source Link
andre314
  • 19k
  • 1
  • 37
  • 73
Loading
Source Link
andre314
  • 19k
  • 1
  • 37
  • 73
Loading