Project

General

Profile

Bug #524

modf

Added by iri over 2 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
VM
Target version:
-
Start date:
05/31/2015
Due date:
% Done:

100%

Estimated time:

Description

This Scol function in the std lib is wrong (or its documentation is wrong).

mod returns the modulo between two integers. It's right.
modf should the same thing with two float numbers. It is incorrect.

More, the current source code of modf is :

  (...)
  double x = MTOF(val0);
  double y = MTOF(val1);
  m->top[m->pp] = FTOM((float)(modf(x, &y)));

In C and C++, modf doesn't return a such "modulo" !
In the code above, y points to the integral part of x. In the top of the heap, it is its decimal part. So, the Scol modf returns only the decimal part of the first given float number.

The current state is this :

fun main ()=
  _showconsole;
  _fooId mod 390 360;  // 30
  _fooF modf 390.0 360.0;  // 0.000000
  0;;

Associated revisions

Revision 7585 (diff)
Added by arkeon over 2 years ago

Kernel :
closes #524
- correction on modf function

Revision 7585 (diff)
Added by arkeon over 2 years ago

Kernel :
closes #524
- correction on modf function

History

#1 Updated by arkeon over 2 years ago

#2 Updated by arkeon over 2 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset r7585.

Also available in: Atom PDF