decimal

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2025 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2025 Dmitry Spasibenko

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntWrapper

type IntWrapper struct {
	// V contains all digits of a decimal value
	V int
	// E is an exponent value the real decimal value is V*10^E. So
	// if E is less than zero, it means that least significant E digits of V
	// goes to the decimal fraction. For example, IntWrapper{V:1234, E:-2} means 12.34
	// if E is greater than 0, than it is a decimal multiplier, so IntWrapper{V:1234, E:2}
	// means 123400 etc.
	E int
}

IntWrapper is a lightweight container to represent a decimal value in int value.

func FromFloat64

func FromFloat64(v float64, e int) IntWrapper

FromFloat64 returns the wrapper for the float64 value v and the decimal exponent e

func (IntWrapper) Float64

func (d IntWrapper) Float64() float64

Float64 returs float64 for the d

func (IntWrapper) String

func (d IntWrapper) String() string

String formats d as decimal value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL