numbers

Format numbers in TextBox as you type

折月煮酒 提交于 2021-01-29 01:33:27
问题 Is there is any way to format numbers in TextBox (on a UserForm) as you type? This way it makes easy to see what figure is being entered. My desired format is: #,##0.00 回答1: This could be considered a slightly " Above the Average " question in terms of difficulty for a newbie so I am going to answer this :) VBA doesn't have what you call a Masked Text Box where you can set formats as #,##0.00 . You can only do a masked textbox for accepting passwords but that is altogether a different thing.

Looping an “If Else Statement” java

我的未来我决定 提交于 2021-01-28 22:44:54
问题 I am attempting to make a simple program in java using Scanner that will allow the user to shoot craps (play dice). 1.This code asks the user to enter how much money they have. The code will ask user to input a bet. Using a random number generator, it will inform the user what they rolled and inform the user how much money they've won/lost. I have been able to successfully tell the computer to inform the user when they have won or lost, when they roll 2,3,7,11, or 12. I am not sure how to

Allow To Only Input A Number - C#

拜拜、爱过 提交于 2021-01-28 21:29:22
问题 I'm fairly new to C#. I'm trying to make a basic program that converts Degrees in Celsius to Fahrenheit. But here's the catch, I want to make sure that the user inputs only a valid number and no characters or symbols. And if the user inputs, for example 39a,23, the Console asks him to enter the number again. Console.WriteLine("Please enter the temperature in Celsius: "); double x = Convert.ToDouble(Console.ReadLine()); Also, I've been making other programs, and I've been wondering - do I

Replacing every number in a string with a random char

ぃ、小莉子 提交于 2021-01-28 07:36:34
问题 I want to replace every number in a string like ABC123EFG with another random char. My idea was to generate a random string with the number of all numbers in $str and replace every digit by $array[count_of_the_digit] , is there any way to do this without a for-loop, for example with regex? $count = preg_match_all('/[0-9]/', $str); $randString = substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyz", $count)), 0, $count); $randString = str_split($randString); $str = preg_replace('/[0-9]+/'

Changing port number in easyphp devserver 17

ⅰ亾dé卋堺 提交于 2021-01-28 07:04:04
问题 I am using EasyPHP Devserver 17. I want to change it port number to 127.0.0.1:786. Because my all application has set to this type only. This new installation has default only 4 port 8080,8000,8008,8888. when ever I am trying to do manually it always reset back to normal. I am not able to change it. 回答1: Open the file eds-app-dashboard.php in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-binaries\httpserver\apachexxx Line 18, add your port number : $ports = array(786,80,8080,8000,8888,8008)

Why protobuf only read the last message as input result?

浪尽此生 提交于 2021-01-27 17:45:39
问题 Usually, we use protobuf to communicate a message, for multiple times, each with different message content. But I found seems the reader side process the whole message, and only the last one is used, like below: $cat 30.proto message hello { required int32 f1=1; required int32 f2=2; optional int32 f3=3; } $cat 30.cpp #include "30.pb.h" #include<fstream> #include<iostream> using namespace std; int main() { fstream fo("./log30.data",ios::binary|ios::out); hello p1,p2,p3; p1.set_f1(1); p1.set_f2

Java 1.7: Sum of Iterable<T extends Number>

放肆的年华 提交于 2021-01-27 07:33:46
问题 I need to create a helper method which allows to create a sum of any Iterable<? extends Number>, because we have many vectors and require a fast method to determine the sum, so I created the following method: static Integer sum(Iterable<Integer> it) { Integer result = 0; for(T next : it) { result += next; } return result; } This method only works for ints however, but we also have doubles and longs. Because you can't have two methods with the same signature (Our compiler thinks Integer sum

Java 1.7: Sum of Iterable<T extends Number>

蓝咒 提交于 2021-01-27 07:31:12
问题 I need to create a helper method which allows to create a sum of any Iterable<? extends Number>, because we have many vectors and require a fast method to determine the sum, so I created the following method: static Integer sum(Iterable<Integer> it) { Integer result = 0; for(T next : it) { result += next; } return result; } This method only works for ints however, but we also have doubles and longs. Because you can't have two methods with the same signature (Our compiler thinks Integer sum

Store very big numbers in an integer in C

为君一笑 提交于 2021-01-24 11:49:52
问题 I need to store a very large number as an integer in a C program, unsigned long int is still too small, I need a very large data type that will still work with the modulo operator (%). 回答1: There are several libraries that can do this GMP OpenSSL's BN If you need it for cryptographic purposes (e.g. RSA as hinted by your need of modulo arithmetic), OpenSSL BN is ideally suited 回答2: I just want to throw in another library to solve this problem, which I just finished: kmbint It is more

Store very big numbers in an integer in C

天大地大妈咪最大 提交于 2021-01-24 11:49:32
问题 I need to store a very large number as an integer in a C program, unsigned long int is still too small, I need a very large data type that will still work with the modulo operator (%). 回答1: There are several libraries that can do this GMP OpenSSL's BN If you need it for cryptographic purposes (e.g. RSA as hinted by your need of modulo arithmetic), OpenSSL BN is ideally suited 回答2: I just want to throw in another library to solve this problem, which I just finished: kmbint It is more