Ticket #481 (closed RFC: fixed)

Opened 13 years ago

Last modified 11 years ago

some basic math ops are missing

Reported by: bsdz Owned by: Paul C. Anagnostopoulos
Priority: normal Milestone:
Component: core Version: trunk
Severity: medium Keywords:
Cc: Language:
Patch status: applied Platform:

Description

Some useful math operators are missing in Parrot.

round() (known by same name in C) cot() (cotangent)

A workaround for now is to use floor(x+.5) for round() and 1/tan for cot.

Attachments

PCA-patch-003.patch Download (7.5 KB) - added by Paul C. Anagnostopoulos 11 years ago.

Change History

in reply to: ↑ description   Changed 12 years ago by jkeenan

Replying to bsdz:

> Some useful math operators are missing in Parrot.
> 
> round() (known by same name in C)
> cot() (cotangent)

csc() (cosecant) also appears to be missing.

  Changed 11 years ago by Paul C. Anagnostopoulos

May I suggest that all four float -> integer conversion functions be included:

ceiling() floor() round() truncate()

  Changed 11 years ago by Paul C. Anagnostopoulos

  • owner set to Paul C. Anagnostopoulos
  • status changed from new to assigned

Changed 11 years ago by Paul C. Anagnostopoulos

  Changed 11 years ago by Paul C. Anagnostopoulos

  • patch set to new

We decided during various chats on #parrot that a round operation should not be added. We didn't want to have to decide what sort of rounding to perform. It was also decided not to add truncate, but I did update the documentation to specify that floating-point to integer conversion is done by truncation. That is now part of the specification of assignment.

I added cot and csc operations for native numbers and also for the Float PMC. These operations were already supported for the Complex PMC.

  Changed 11 years ago by cotto

+1 to apply this. The patch looks sane and all tests pass. If nobody beats me to it, I'll plan on applying this later today.

  Changed 11 years ago by Paul C. Anagnostopoulos

  • status changed from assigned to closed
  • resolution set to fixed
  • patch changed from new to applied

Thanks to cotto for applying this patch in r48564.

Note: See TracTickets for help on using tickets.