summary refs log tree commit diff stats
path: root/lib/pure/rationals.nim
Commit message (Collapse)AuthorAgeFilesLines
* Support `div`, `mod`, floorDiv and floorMod for Rationals (#7918)Koki Fushimi2018-06-011-0/+36
| | | | | | | | * Support `div`, `mod`, floorDiv and floorMod for Ratinoals. * Bug fix and add tests. * Update changelog
* Use safe limit for toRational(float, int) (#7021)Sergey Avseyev2018-01-031-3/+8
| | | | | | | | | | Current limit `high(int32)` is not safe for 32-bit platforms and it will overflow (even when running its own test suite). Similar behaviour would be when try to set limit to `high(int64)` on 64-bit platforms. This change selects safe maximum value based on platform size of int. Safe maximum considered half of int size (for backward compatiblity).
* Make toRational proc to loop through integers (#6633)konqoro2017-10-301-18/+15
|
* make tests green againAndreas Rumpf2017-10-301-2/+2
|
* rationals.toRational now uses an algorithm based on continued fractions; ↵Andreas Rumpf2017-10-301-45/+32
| | | | refs #4968
* made test green for 32bit systemAraq2016-09-301-1/+1
|
* Fix toRational overflow by calculating internally with int64s (fixes #4194)def2016-05-221-11/+11
|
* Fixed a typo in proc `-`(x: T, y: Rational[T])pgkos2016-03-181-1/+1
|
* Add toRational(float) conversion from any float to closestJamesP2015-10-041-0/+62
| | | | approx for specified precision
* add a few type checks to limit type to SomeIntegerJamesP2015-10-011-3/+3
| | | | | | (adding a compund type to the Rational type definition made it too difficult to define new variables using integer literals)
* add assertion for zero denominatorJamesP2015-10-011-0/+1
|
* lib: Trim .nim files trailing whitespaceAdam Strzelecki2015-09-041-1/+1
| | | | via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
* lib/pure/p-t - Dropped 'T' from typespdw2015-06-041-2/+2
|
* Merge pull request #2486 from endragor/rational-hashAndreas Rumpf2015-04-081-0/+14
|\ | | | | Add hash proc for Rational
| * Added hash proc for RationalRuslan Mustakov2015-04-081-0/+14
| |
* | Added procvar pragma to rationals.cmpRuslan Mustakov2015-04-081-1/+1
|/
* Fix toRationaldef2015-04-071-2/+2
|
* Add for rationalsdef2015-02-271-0/+4
|
* Add for easier intialization of rationalsdef2015-02-271-26/+32
|
* Make Rational an objectdef2015-02-241-31/+36
|
* Make rationals genericdef2015-02-201-28/+33
|
* Fix typodef2015-02-191-1/+1
|
* Change author of rationals moduledef2015-02-191-1/+1
|
* Update toInt docdef2015-02-161-2/+2
|
* Fix division and add testsdef2015-02-161-15/+42
|
* Change rationals.toInt behaviourdef2015-02-161-4/+4
|
* Move rational.nim to rationals.nimdef2015-02-161-0/+228
t/999spaces.cc?h=hlt&id=5d2a486d9de25dc98d19ef91154e12a8c8efbe87'>5d2a486d ^
dfdfc7e9 ^
215365d4 ^
f7631430 ^
215365d4 ^
5d2a486d ^

215365d4 ^
5d2a486d ^
1ead3562 ^
5d2a486d ^
1ead3562 ^
215365d4 ^
dfdfc7e9 ^
691b529e ^












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

                                                                              


                                                                           



                                                        
                                        
                                                                                                    
                     
                                          
                                                                                                                           

                                   


                                 


                                                             
                                    
                                                            


                       



                                                       


                                                 

                                            

                                 
                                       
                                          
   
                                            
                                     
                                            
                                     
   
                                       
                                       

                                            
                                     


                                             
         


                                       
                                          
                                         
   
                  
         
                            

                                                  
                                            
                            
                                             
                              
                                                   
                
                  












                                                                                               
//: Since different layers all carve out different parts of various namespaces
//: (recipes, memory, etc.) for their own use, there's no previous place where
//: we can lay out the big picture of what uses what. So we'll do that here
//: and just have to manually remember to update it when we move boundaries
//: around.
//:
//:: Memory
//:
//: Location 0 - unused (since it can help uncover bugs)
//: Locations 1-899 - reserved for tests
//: Locations 900-999 - reserved for predefined globals in Mu scenarios, like keyboard, screen, etc.
:(before "End Reset")
assert(Max_variables_in_scenarios == 900);
//: Locations 1000 ('Reserved_for_tests') onward - available to the allocator in chunks of size Initial_memory_per_routine.
assert(Reserved_for_tests == 1000);

//:: Recipes
//:
//: 0 - unused (IDLE; do nothing)
//: 1-199 - primitives
assert(MAX_PRIMITIVE_RECIPES < 200);
//: 200-999 - defined in .mu files as sequences of primitives
assert(Next_recipe_ordinal == 1000);
//: 1000 onwards - reserved for tests, cleared between tests

//:: Depths for tracing
//:
//: 0 - errors
//: 1-99 - app-level trace statements in Mu
//: 100-9999 - call-stack statements (mostly label run)
assert(Initial_callstack_depth == 100);

//:: Summary of transforms and their dependencies
//: begin transforms
//:   begin instruction inserting transforms
//:     52 insert fragments
//:      ↳ 52.2 check fragments
//:   ---
//:     53 rewrite 'stash' instructions
//:   end instruction inserting transforms
//:
//:   begin instruction modifying transforms
//:     56.2 check header ingredients
//:      ↳ 56.4 fill in return ingredients
//:     48 check or set types by name
//:
//:     begin type modifying transforms
//:       56.3 deduce types from header
//:     ---
//:       30 check or set invalid containers
//:     end type modifying transforms
//:         ↱ 46 collect surrounding spaces
//:      ↳ 42 transform names
//:         ↳ 57 static dispatch
//:   ---
//:     13 update instruction operation
//:     40 transform braces
//:     41 transform labels
//:   end instruction modifying transforms
//:    ↳ 60 check immutable ingredients
//:
//:   begin checks
//:   ---
//:     21 check instruction
//:     ↳ 61 check indirect calls against header
//:     ↳ 56 check calls against header
//:     ↳ 43 transform 'new' to 'allocate'
//:     30 check merge calls
//:     36 check types of return instructions
//:     43 check default space
//:     56 check return instructions against header
//:   end checks
//: end transforms

//:: Summary of type-checking in different phases
//: when dispatching instructions we accept first recipe that:
//:   strictly matches all types
//:   maps literal 0 or literal 1 to boolean for some ingredients
//:   performs some other acceptable type conversion
//:     literal 0 -> address
//:     literal -> character
//: when checking instructions we ensure that types match, and that literals map to some scalar
//:   (address can only map to literal 0)
//:   (boolean can only map to literal 0 or literal 1)
//:     (but conditionals can take any scalar)
//: at runtime we perform no checks