Code Monkey home page Code Monkey logo

gocalc's Introduction

Simple Go Gtk Calculator using go-gtk (github.com/mattn/go-gtk)

	go get github.com/abiosoft/gocalc

Depends on go-gtk

	go get github.com/mattn/go-gtk/gtk

gocalc's People

Contributors

abiosoft avatar xyproto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gocalc's Issues

float does not exist, only float32 and float64

Hello,

According to the go language specification, and my compiler, float does not exist, only float32 and float64. Here is a patch that makes this project compile on my computer (64-bit Arch Linux).

Best regards,
Alexander Rødseth

(crated with git diff)

diff --git a/Makefile b/Makefile
index 9cc86c4..04355f3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
-include $(GOROOT)/src/Make.$(GOARCH)
+include $(GOROOT)/src/Make.inc
 
 TARG=calculator
 GOFILES=\
    calculator.go\
    gui.go\
 
-include $(GOROOT)/src/Make.cmd
\ No newline at end of file
+include $(GOROOT)/src/Make.cmd
diff --git a/calculator.go b/calculator.go
index 15bbf0f..702ff4b 100644
--- a/calculator.go
+++ b/calculator.go
@@ -6,12 +6,12 @@ import (
 
 //Result
 var Result struct {
-   last     float  //stores last result
+   last     float32  //stores last result
    operator string //the next operator to use
    active   bool   //whether calculation has started
 }
 //perform calculation
-func calculation(val float, operator string) {
+func calculation(val float32, operator string) {
    if !Result.active {
        Result.last = val
        Result.operator = operator
diff --git a/gui.go b/gui.go
index 6d1879f..ebc5cf9 100644
--- a/gui.go
+++ b/gui.go
@@ -22,7 +22,7 @@ func quit() {
 func input(b *gtk.GtkButton) func() {
    return func(){
        if strings.Index(operators, b.GetLabel()) != -1 {
-           val, _ := strconv.Atof(screen.GetText())
+           val, _ := strconv.Atof32(screen.GetText())
            calculation(val, b.GetLabel())
            screen.SetText(getResult())
            inputMode = false

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.