Module: FixedPntModule
- Defined in:
- lib/fixedpnt.rb
Instance Method Summary collapse
-
#fp(*args) ⇒ Object
TODO: Better way?.
-
#required_fp_format(smallest_representable_value, biggest_overall_value) ⇒ Object
Calculates the required Fixed-Point format for given smallest_representable_value and biggest_overall_value.
Instance Method Details
#fp(*args) ⇒ Object
TODO: Better way?
553 554 555 |
# File 'lib/fixedpnt.rb', line 553 def fp( *args ) FixedPnt.new(*args) end |
#required_fp_format(smallest_representable_value, biggest_overall_value) ⇒ Object
Calculates the required Fixed-Point format for given smallest_representable_value and biggest_overall_value. Returns: [required_no_of_bits, required_fractional_width]
561 562 563 564 565 566 |
# File 'lib/fixedpnt.rb', line 561 def required_fp_format(smallest_representable_value, biggest_overall_value ) smallest_bin_place = smallest_representable_value.max_significant_bin_place # "Nachkommastelle" -> negatives Vorzeichen biggest_bin_place = biggest_overall_value.max_significant_bin_place # "Nachkommastelle" -> negatives Vorzeichen [(biggest_bin_place - smallest_bin_place + 2).to_i, (-smallest_bin_place).to_i] end |