remove div and add div10
general division is for another day, the 10 version is manageable also same code produces mod10 wip
This commit is contained in:
@ -13,7 +13,7 @@ class Integer < Value
|
||||
int num = as_char()
|
||||
str = str.push_char( num )
|
||||
else
|
||||
int rest = self / 10
|
||||
int rest = self.div10()
|
||||
str = rest.as_string( str )
|
||||
rest = rest * 10
|
||||
rest = self - rest
|
||||
@ -33,14 +33,7 @@ class Integer < Value
|
||||
return self
|
||||
end
|
||||
|
||||
int div( Integer by)
|
||||
int ret = self / by
|
||||
return ret
|
||||
end
|
||||
|
||||
int mod(Integer by)
|
||||
int base = self / by
|
||||
base = base * by
|
||||
return self - base
|
||||
int mod4()
|
||||
return self & 3
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,7 @@ class Word < Object
|
||||
|
||||
int char_at(int index)
|
||||
int word_index = index - 1
|
||||
word_index = word_index / 4
|
||||
word_index = word_index >> 2
|
||||
word_index = word_index + 3
|
||||
int rest = index - 1
|
||||
rest = rest.mod(4)
|
||||
@ -23,7 +23,7 @@ class Word < Object
|
||||
self.set_length(index)
|
||||
|
||||
int word_index = index - 1
|
||||
word_index = word_index / 4
|
||||
word_index = word_index >> 2
|
||||
word_index = word_index + 3
|
||||
|
||||
int rest = index - 1
|
||||
|
Reference in New Issue
Block a user