[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #63995] Octave c++ method .double_value on (in
From: |
Hendrik K |
Subject: |
[Octave-bug-tracker] [bug #63995] Octave c++ method .double_value on (intmax ("uint64")-1) |
Date: |
Mon, 3 Apr 2023 21:10:46 -0400 (EDT) |
URL:
<https://savannah.gnu.org/bugs/?63995>
Summary: Octave c++ method .double_value on (intmax
("uint64")-1)
Group: GNU Octave
Submitter: koerhen
Submitted: Tue 04 Apr 2023 01:10:44 AM UTC
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Inaccurate Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: dev
Discussion Lock: Any
Operating System: GNU/Linux
Fixed Release: None
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Tue 04 Apr 2023 01:10:44 AM UTC By: Hendrik K <koerhen>
When using the octave c++ method ".double_value" on an octave-value container
with a double representing uintmax-1, the result cannot be represented as the
correct <uint64_t> value, but is always zero.
Example
=======
#include <octave/oct.h>
DEFUN_DLD(ff, args, nargout,
"-*- texinfo -*-\n\
@deftypefn {} {} ff (@var{V})\n\
@end deftypefn")
{
octave_value ret;
octave_stdout << args (0).double_value () << "\n";
uint64_t t1 = (uint64_t) args (0).double_value ();
octave_stdout << t1 << "\n";
uint64_t t2 = static_cast<uint64_t> (args (0).double_value ());
octave_stdout << t2 << "\n";
uint64_t t4 = std::trunc(args (0).double_value ());
octave_stdout << t4 << "\n";
double t_d = args (0).double_value ();
uint64_t t5 = (uint64_t) t_d;
octave_stdout << t5 << "\n";
double n_d = args (0).double_value ();
octave_stdout << n_d << "\n";
uint64_t t6 = static_cast<uint64_t> (n_d);
octave_stdout << t6 << "\n";
return ovl (ret);
}
---------------------------------------------------
clear ff; mkoctfile ("ff.cc");
ff(intmax ("uint64")-1)
1.84467e+19
0
0
0
0
1.84467e+19
0
This was detected as part of the bug https://savannah.gnu.org/bugs/?63992
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?63995>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #63995] Octave c++ method .double_value on (intmax ("uint64")-1),
Hendrik K <=